Giter Site home page Giter Site logo

fox's Introduction

Fox state manager

Fox is a simple key value observable state manager

Logic

keep everything simple, share functions and data you want from a component either set or get and keep track of their update on other components!

every item has a key that you can access directly from fox object or get it from the manager

fox object is the big object that contains everything we publish

manager is the functions that we use to interact with fox

Installation

npm i @nikandlv/fox

Usage

import it

import {fox,manager} from '@nikandlv/fox'

use it!

you can publish what ever you want

manager.publish(key,value)

manager.publish("test",()=> { console.log("test") })

manager.publish("test1","im just a string")

and you can unPublish them when you have to (when the component is not mounted anymore)

manager.unpublish(key)

manager.unpublish("test")

manager.unpublish("test2")

then you can get them where you want like so

manager.get(key,default_value)

manager.get("test",null)

manager.get("test2","test2 not found!")

the second parameter is the default value if the key does not exist

or if you are sure you can access it directly at

fox.key

fox.test

fox.test2

the key can also be as you want. for example

manager.publish("foo.bar","im just a string")

will be

fox.foo.bar

Events

Listener when key is published

manager.onPublish(key,event_function)

runs once and asap when the key is available

Listener when key is unpublished

manager.onUnpublish(key,event_function)

runs once and asap when the key is available

Listener when key is updated / observe

manager.onUpdate(key,event_function)

runs every time and asap when the key is updated

fox's People

Contributors

nikandlv avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

fox's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.