1.0.6 • Published 2 years ago

statio-js v1.0.6

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

Docs

Github.com link. You will find the documentation and you can contribute too


Usage

    const statio = require('statio');

Statio.js

A library for handling the changes made to the state.

Initialization of State


statio.createState(string)

  • It's a function
  • It creates the state
  • Store it in a (const) variable
  • Accepts string (THE NAME OF THE STATE)
const profileState = statio.createState("userName")
  • To change state, call the .set(any)

createState.set(value)

  • It is a function
  • Use to change the state
  • use it together with createState
profileState.set("Statio Developer")

Getting the Changes of State


createState.attach(function)

  • it is a function
  • use to get the effect of the 1 state changing
  • Store it in a variable if you are going to detach it
  • Accept a function in the parameters
profileState.attach(function (state) {
    console.log("The New profile image is " + state);
})

createState.attach.detach()

  • it is a function
  • It detaches the attachment into state
  • only works if you are going to call it inside attach variable
  • to attach it again, store this in a variable and use .attach()
const profAttach = profileState.attach(function (state) {
    console.log("The New profile image is " + state);
})
profAttach.detach()
//to attach again
const profAttach = profileState.attach(function (state) {
    console.log("The New profile image is " + state);
})
const detachProf = profAttach.detach()
detachProf.attach()

createState.get()

  • It is a function
  • Only get the current state when run
  • Returns the current state
console.log(profAttach.get())
//logs Statio Developer

statio.catchEffect(function, array)

  • use it independently
  • it is like .attach, but it accepts multiple state names
  • the array only accepts array of the state name (string)
statio.catchEffect(function (){
    console.log("Change recieved");
},["userName", "userEmail"]) 
1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago