-
Notifications
You must be signed in to change notification settings - Fork 13
ElmFragment and ElmActivity
To simplify writing Elm screens and reducing the amount of errors elmslie-android
provides ElmFragment and ElmActivity classes. They handle implementing Elm architecure on android. After extending them there's only a minimal set of methods to implement:
- val initEvent: Event
Should be set to some specific Event which will be sent the first to initialize the Store
- fun createStore(): Store
It should create and ElmStore instance passing to it the necessary initial State, Actor and Reducer
- fun render(State)
Draw the State on the screen. For example set views visibility, text or recycler view items.
- fun handleEffects(Effect) - optional
Handles screen effect. It's guaranteed to be called insode onResume/onPause state both for Fragment and Activity.
- fun mapList(State): List - optional
This is used to asynchronously map list items for recycler view. The returned set of items will be passed to the next method, renderList
- fun renderList(List) - optional
Called with the items you will return inside mapList, but on the main thread.