Skip to content

Nap as a flux-like store #14

@cristiano-belloni

Description

@cristiano-belloni

This is the other side of #13: I'm using redux.js at home and I was wondering how to make a flux-like store with Nap / resourceful.

Turns out, IMHO, that they are conceptually very similar:

  • Redux has actions. An action is "the only source of information for a store", and "must have a type property that indicates the type of action being performed". Sounds similar? Our RESTful requests are actions, with type set to one of the HTTP verbs and the rest of the data as a payload.
  • Redux has reducers and stores. Reducers "specify how the application’s state changes in response". They are essentially request handlers. The store holds state, and can be easily achieved within a module that uses immutables.
  • Redux has middlewares, which come out of the box with Nap.
  • The only thing we don't have currently is subscribing to a store, aka being called back when the store changes. We had the stream type implementation in am-address that would be perfectly suited for it and probably could have a space in Nap.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions