Riot Action
This library provides an easy way to separate the view (tag
) and the logic (action
).
NOTE: Riot Action is still in development
Basic usage
Write the view and apply the mixin riot-action
:
Clear
Write the logic as a separated class:
// Actions // - actions are triggered via events // - actions are automatically registered to its view as an events { someAPI } { someAPI }
Combine the view and the logic:
riot // registers riot-action as a middlewareriot
Or:
import Memo from './action-memo'
In both cases, the Action is passed by its attributes.
Flow
- Events: the view use
this.trigger()
to tell something to the action - Actions: do something in the action
- Updates: the action use
this.update()
to tell something to the view
Action
class has update()
method and it's the only way to control the view.
Routings
Riot Action works perfectly with riot-route
. And it has an utility class. You can create a new instance by view.mount()
. The class has route
method to register its route, and the method is chainable.
// actions // tags // registers riot-action as a middlewareriot // routingsview routestarttrue
HTML router (planned)
This feature has not been implemented yet.
import Home from './action-home'import Detail from './action-detail'