Skip to content

Latest commit

 

History

History
33 lines (21 loc) · 1.58 KB

FP.md

File metadata and controls

33 lines (21 loc) · 1.58 KB

I've neglected to document this portion as well as I'd like.

For now, please just browse the source (it's not massive) and follow the types.

Scalaz

libraryDependencies += "com.github.japgolly.scalajs-react" %%% "ext-scalaz71" % "0.9.0"

Included is a Scalaz module that facilitates a more functional and pure approach to React integration. This is achieved primarily via state and IO monads. Joyously, this approach makes obsolete the need for a "backend".

State modifications and setState callbacks are created via ReactS, which is conceptually WriterT[M, List[Callback], StateT[M, S, A]]. ReactS monads are applied via runState. Vanilla StateT monads (ie. without callbacks) can be lifted into ReactS via .liftR. Callbacks take the form of IO[Unit] and are hooked into HTML via ~~>, e.g. button(onclick ~~> T.runState(blah), "Click Me!").

Also included are runStateF methods which use a ChangeFilter typeclass to compare before and after states at the end of a state monad application, and optionally opt-out of a call to setState on a component.

There's only one example at the moment: State monad example.

Monocle

libraryDependencies += "com.github.japgolly.scalajs-react" %%% "ext-monocle" % "0.9.0"

A module with a extensions for Monocle also exists under ext-monocle.

There's one example online that demonstrates Monocle usage: ExternalVar example.