Coder Social home page Coder Social logo

bagx-js's Introduction

BagX-JS

First OOP attempt to test my understanding about tate management by creating a simple library. //I haven't run some tests of my library because I only wrote it out of boredom.//

Getting Started

Store initialization

You can simply initialize the store if you haven't decided what state features and methods you want to include by the given sample code snippet below.

var store = new BagX();

The class BagX() can take 2 arguments which are stateFeatures and methods; both arguments are of object data type.

var store = new BagX({feature1: ..., feature2: ..., ....}, {method1: ...., method2...., ....})

Adding stateFeature and method

Both parameters, obj and param, are in object data type. The method that is added is not writable, this means the user can't change the existing function of a certain method once it was added.

store.addStateFeature(obj);
store.addMethod(param);

dispatch

The dispatch is where what method you want to execute from the store and it takes two arguments action and payload. The action argument is of string type while the payload is null by default.

store.dispatch(action,payload=null);

mutate

The mutate function is where you change the contents of the state. It takes two arguments, stateFeature and payload, the payload is null by default and stateFeature is of string data type.

store.mutate(stateFeature,payload=null);

publish

The publish function is where you get the contents of the state. It takes stateFeature as the argument and returns the contents of stateFeature from the store's state. The argument is initialized to null, if it's not stated, it'll return the state contents from the store.

store.publish(stateFeature=null);

bagx-js's People

Contributors

juddbaguio avatar

Watchers

James Cloos avatar

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.