| Copyright | (C) 2016-2026 David M. Johnson |
|---|---|
| License | BSD3-style (see the file LICENSE) |
| Maintainer | David M. Johnson <code@dmj.io> |
| Stability | experimental |
| Portability | non-portable |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Miso.Binding
Contents
Description
Data Bindings
miso includes an experimental feature that allows fields of different models to be synchronized
against each another in response to model changes. See Binding. Note this feature is
experimental, it is recommended to use asynchronous Component communication (like broadcast) by default.
This module exposes combinators to construct a Binding which holds two lenses that will alter
Component model state along the parent-child relationship using a Lens. Practically, this means when
one Component is marked as dirty, another Component will also potentially will be marked as
dirty if they are connected along an edge (Binding).
See the miso-reactive project for more information.
Synopsis
- data Binding parent child
- = ParentToChild (parent -> field) (field -> child -> child)
- | ChildToParent (field -> parent -> parent) (child -> field)
- | Bidirectional (parent -> field) (field -> parent -> parent) (child -> field) (field -> child -> child)
- (<-->) :: Lens parent field -> Lens child field -> Binding parent child
- (<--) :: Lens parent a -> Lens model a -> Binding parent model
- (-->) :: Lens parent a -> Lens model a -> Binding parent model
- (<--->) :: Lens' parent field -> Lens' child field -> Binding parent child
- (<---) :: Lens' parent field -> Lens' child field -> Binding parent child
- (--->) :: Lens' parent field -> Lens' child field -> Binding parent child
Types
data Binding parent child Source #
Binding is used to synchronize parent and child model changes at the granularity specified by a Lens
This can be thought of as establishing an "edge" in the Component graph,
whereby events cause model change synchronization to "ripple" or "pulsate"
through the views. The "reactivity" of the graph is constructed manually
by the end-user, using the edge primitives -->, <--, <--> (reactive combinators).
main :: IO ()
main = run app { bindings = [ parentLens <--> childLens ] }
Since: 1.9.0.0
Constructors
| ParentToChild (parent -> field) (field -> child -> child) | |
| ChildToParent (field -> parent -> parent) (child -> field) | |
| Bidirectional (parent -> field) (field -> parent -> parent) (child -> field) (field -> child -> child) |
Combinators
(<-->) :: Lens parent field -> Lens child field -> Binding parent child infix 0 Source #
Bidirectionally binds a child field to a parent field, using Lens
This is a bidirectional reactive combinator for a miso Lens.
Since: 1.9.0.0
(<--) :: Lens parent a -> Lens model a -> Binding parent model infixl 0 Source #
Unidirectionally binds a child field to a parent field
Since: 1.9.0.0
(-->) :: Lens parent a -> Lens model a -> Binding parent model infixr 0 Source #
Unidirectionally binds a parent field to a child field
Since: 1.9.0.0
(<--->) :: Lens' parent field -> Lens' child field -> Binding parent child infix 0 Source #
Bidirectionally binds a child field to a parent field, using Lens'
This is a bidirectional reactive combinator for a van Laarhoven Lens'
Since: 1.9.0.0