3.0.4 • Published 23 days ago

nixix v3.0.4

Weekly downloads
-
License
MIT
Repository
-
Last release
23 days ago

NixixJS - A JavaScript UI library or framework used for creating performant user interfaces.

Table of Contents

Getting Started

To get started, you have to initialize your project with npm, that is, if you haven't already. Type this in the terminal:

  npm init -y 

Then, configure your workspace. To do that, type:

  npm install create-nixix-app
  npx create-nixix-app

The final step is to download the library, type:

  npm install nixix

Now you are ready to code 😁!!!!

Features

  • NO Virtual DOM: Nixix creates real DOM nodes and efficiently renders and updates the nodes.
  • 🚀 Blazingly fast reactive primitives for DOM updates with signals and stores.
  • Side effects with effect function.
  • Render once mental model - components render only once.
  • Component architecture.
  • ReactJS-like: Nixix has a really low learning curve for developers coming from ReactJS and SolidJS

List of Apis

  • Signal : signals are reactive values that can change over time. They can be created with two functions - callSignal and callStore.

  • callSignal : function used to create reactive values with JavaScript primitives. It returns the value passed to it and a setter.

      import { callSignal } from 'nixix/primitives';
      
      const App = () => {
        const [value, setValue] = callSignal<string>('John');
    
        return (
          <>
            <div>{value}</div>
            <button on:click={() => setValue('Jane')}>Click me</button>
          </>
        )
      }
  • callStore : function used to create reactive values with JavaScript objects and arrays. It returns the value passed to it and a setter.

      import { callStore } from 'nixix/primitives';
    
      type Username = { name: string };
    
      const App = () => {
        const [username, setUserName] = callStore<Username>({ name: 'John' });
    
        return (
          <>
            <div>{username.name}</div>
            <button on:click={() => setUserName({ name: 'Jane' })}>Click me</button>
          </>
        )
      }
    
      // usage with arrays.
    
      const App = () => {
        const [username, setUserName] = callStore<Username>(['John']);
    
        return (
          <>
            <div>{username[0]}</div>
            <button on:click={() => setUserName(['Jane'])}>Click me</button>
          </>
        )
      }
  • callRef : This function is used to get the a dom element instance, to do some regular dom operations on them.

      import { callRef, effect, callSignal } from 'nixix/primitives';
      
      const App = () => {
        const myDiv = callRef<HTMLDivElement>()
        const [display, setDisplay] = callSignal(true);
        effect(() => {
            if (!display) {
              myDiv.current.remove();
            }
          }
        )
    
        return (
          <>
            <div bind:ref={myDiv} >Hello Nixix</div>
            <button on:click={() => setDisplay(false)} >Set Display</button>
          </>
        )
      }
    
      // refs have a current property whose value is the dom element which has its bind:ref prop's value as that ref.
      // once the signal's value is set to false, the dom element is removed from the dom. 
  • effect : This function is used to perform side effects when a reactive value changes. It subscribes to the latest created signal and calls the callback function passed to it after some time. It can also subscribe to other signals when passed an array of the signals to subscribe to and be called once and without subscribing to any signal.

    import { callSignal, callStore, effect } from 'nixix/primitives';
    
    const App = () => {
      const [value, setValue] = callSignal(0);
      effect(() => {
          console.log(value.value)
        },
      )
      // calls the function. Whenever the signal's value changes, it calls the function again. 
      
      return (
        <button on:click={() => setValue(Math.random())} >Change Number</button>
      )
    };
    
    // they can also be called once without subscribing to any signal by passing 'once' as the second argument
    effect(() => {
        console.log('Ran once')
      },
      'once'
    )
    
    // they can also subscribe to multiple signals by passing an array of signals as the third argument
    const [count, setCount] = callSignal(0);
    const [store, setStore] = callStore({name: 'John'});
    effect(() => {
        console.log('Multiple Signals');
      },
      null,
      [count]
    )  
  • renderEffect : This function does everything the effect function does, but it calls the callback function immediately, unlike the effect function which does so after some time

  • asyncComponent : This function accepts an argument which is a function that should have a return type of 'Promise<JSX.Element>'. It is used to override the errors IDEs throw when a functional component has the a return type of 'Promise<JSX.Element>'.

  • Suspense : This is a higher order component that is used to show a loader while an asynchronous operation which will eventually return some JSX is ongoing. It requires two props:

    • fallback : This is the loader which the component will show until the async operation is completed.
    • onError : This is the what the component will show if the async operation fails or rejects.
      import { Suspense, asyncComponent } from 'nixix/hoc';
    
      const AsyncToReturnJSX = asyncComponent(() => {
        return new Promise((resolve, reject) => {
          setTimeout(() => {
            resolve(
              <div>Returned JSX</div>
            )
          }, 2000);
        })
      });
    
      const App = () => {
    
        return (
          <>
            <div>Hello Nixix</div>
            <Suspense fallback={<div>Loading...</div>} onError={`Couldn't return any JSX`} >
              <AsyncToReturnJSX />
            </Suspense>
          </>
        )
      }

Contributors

3.0.4

23 days ago

3.0.3

23 days ago

3.0.2

24 days ago

3.0.1

1 month ago

3.0.0

1 month ago

2.2.1

3 months ago

2.2.0

3 months ago

2.1.1

3 months ago

2.1.0

4 months ago

2.0.14

4 months ago

2.0.13

4 months ago

2.0.11

4 months ago

2.0.12

4 months ago

2.0.9

4 months ago

2.0.5

4 months ago

2.0.7

4 months ago

2.0.6

4 months ago

2.0.8

4 months ago

2.0.3

5 months ago

2.0.2

5 months ago

2.0.4

5 months ago

2.0.1

5 months ago

2.0.0

5 months ago

1.5.14

7 months ago

1.5.13

7 months ago

1.5.16

7 months ago

1.5.15

7 months ago

1.5.18

7 months ago

1.5.17

7 months ago

1.5.19

7 months ago

1.5.21

6 months ago

1.5.20

6 months ago

1.5.23

6 months ago

1.5.22

6 months ago

1.5.24

6 months ago

1.5.9

8 months ago

1.5.8

8 months ago

1.5.7

8 months ago

1.5.6

8 months ago

1.5.5

8 months ago

1.5.4

8 months ago

1.5.3

8 months ago

1.5.2

8 months ago

1.5.1

8 months ago

1.5.0

8 months ago

1.5.10

8 months ago

1.5.12

8 months ago

1.5.11

8 months ago

1.4.20

11 months ago

1.4.22

11 months ago

1.4.21

11 months ago

1.4.24

10 months ago

1.4.23

10 months ago

1.4.26

10 months ago

1.4.25

10 months ago

1.4.27

9 months ago

1.4.13

11 months ago

1.4.15

11 months ago

1.4.14

11 months ago

1.4.17

11 months ago

1.4.16

11 months ago

1.4.19

11 months ago

1.4.18

11 months ago

1.4.6

1 year ago

1.4.5

1 year ago

1.4.4

1 year ago

1.4.3

1 year ago

1.4.2

1 year ago

1.4.1

1 year ago

1.4.0

1 year ago

1.4.9

12 months ago

1.4.11

12 months ago

1.4.8

1 year ago

1.4.7

1 year ago

1.4.12

12 months ago

1.2.0

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.2.3

1 year ago

1.2.2

1 year ago

1.1.3

1 year ago

1.3.0

1 year ago

1.2.1

1 year ago

1.1.2

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago