Skip to content

Instantly share code, notes, and snippets.

@elyphas
Created February 4, 2019 19:19
Show Gist options
  • Save elyphas/77f85eeea5b61b163ac61a6b82a9adf8 to your computer and use it in GitHub Desktop.
Save elyphas/77f85eeea5b61b163ac61a6b82a9adf8 to your computer and use it in GitHub Desktop.
package spatutorial.client.modules
import outwatch.util.Store
import spatutorial.shared.Articulo
import monix.execution.Scheduler.Implicits.global
object StoreProv {
sealed trait ActionArticulo
case object Search extends ActionArticulo
case object Clean extends ActionArticulo
case class Found(lst: Seq[Articulo]) extends ActionArticulo
case class AppState(lst: Seq[Articulo])
val reducer: (AppState, ActionArticulo) => AppState = (s, a ) => a match {
case Found(lst) => AppState(lst = lst )
case Clean => AppState(Seq.empty[Articulo])
case _ => AppState(Seq.empty[Articulo])
}
val initialState = AppState( Seq.empty[Articulo] )
val store = Store.create[AppState, ActionArticulo](initialState, reducer(_,_) ).unsafeRunSync()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment