- Notifications
You must be signed in to change notification settings - Fork4
Realt is a new way to work with Redux inspired by Alt
License
i-kitaev/realt
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Realt is a new way to work withRedux inspired byAlt
If you want to skip the docs and jump straight to the code, you should check out /examples folder, there you'll find some of Redux examples migrated to realt
npm install --save realtimport{createAction}from'realt';constaddText=createAction('addText');expect(addText.toString()).toEqual('ADD_TEXT');expect(addText('Hello world')).toEqual({type:'ADD_TEXT',payload:'Hello world'});
import{createActions}from'realt';constactions=createActions(['create','delete']);
import{createActions}from'realt';constactions=createActions({create(id){returnid;},update(id,data){return{ id, data}}});
import{createActions}from'realt';classActions{constructor(){this.generate('create');}update(id,data){return{ id, data};}}constactions=createActions(Actions);
You can use this method in ActionsClass constructor, it'll setup actions which simply pass forward all incoming data
Note: all of the generated actions will receive only 1 parameter, so your data should be wrapped in an object
import{createReducer}from'realt';constinitialState=[{id:0,title:'Use Realt',}];constreducer=createReducer({create(state,id){// or handleCreate/reducerForCreate},update(state,id){// or handleUpdate/reducerForUpdate}},initialState);
import{createReducer}from'realt';importactionsfrom'../actions';classReducer{constructor(){this.bindAction(actions.create,this.handleCreate);this.bindHandler(this.handleDelete,actions.delete);}getinitialState(){return[{id:0,title:'Use Realt',}];}handleCreate(state,id){returnstate.concat({ id,title:'New entity'});}handleDelete(state,id){returnstate.filter(entity=>entity.id!==id);}}exportdefaultcreateReducer(Reducer);
Here you must bring an initial snapshot of your view's state
This method is a bridge between your reducer and certain action type.When you call it, you're connecting the data flow from some action right into the store
About
Realt is a new way to work with Redux inspired by Alt
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.
