nytimes / Store

Android Library for Async Data Loading and Caching

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Create Payload Store

digitalbuddha opened this issue · comments

Stores are great but they are currently dependent on getting data from a network. I'd like to make a new type of store, this store can be used for events or for pushing your own payload through.

Example of a state store.

stateStore.push(new State("buttonClicked",buttonClickedPayload))
stateStore.push(new State("loading",buttonClickedPayload))
stateStore.push(new State(CameraOpenedState.class,payload))


stateStore.
.filterByState("buttonClicked)
.subscribe(//do something when a button is clicked with input fields)

stateStore.
.filterByState("loading")
.subscribe(//show progress bar")

The thinking is that you should be able to use a store to make a reactive session/state management flow. Everyone has access to a store to push a new state into it, then any screen can subscribe to filtered states from the store that they are interested in. Use then have all the rx operators at their disposal like ability to cache all responses for state restoration.

Would love suggestions of how this should work.

Will be doing as a seperate lib