reflex-dom-retractable: Routing and retractable back button for reflex-dom

[ frp, gui, html, javascript, library, mit, reactive, reactivity, reflex, user-interface, user-interfaces, web ] [ Propose Tags ] [ Report a vulnerability ]

Library that automates widget switches and back button retract stack. See README.md


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1.0.0, 0.1.3.0, 0.1.4.0, 0.1.5.0, 0.1.6.0, 0.1.7.0
Change log CHANGELOG.md
Dependencies base (>=4.7 && <4.15), containers (>=0.5 && <0.7), jsaddle (>=0.9 && <0.10), mtl (>=2.1 && <2.3), ref-tf (>=0.4 && <0.5), reflex (>=0.6 && <0.9), reflex-dom (>=0.5 && <0.7) [details]
License MIT
Copyright 2019 ATUM SOLUTIONS AG
Author Anton Gushcha, Aminion, Vladimir Krutkin, Levon Oganyan
Maintainer Anton Gushcha <ncrashed@protonmail.com>, Vladimir Krutkin <krutkinvs@gmail.com>
Category Reflex, FRP, Web, GUI, HTML, Javascript, Reactive, Reactivity, User Interfaces, User-interface
Source repo head: git clone https://github.com/hexresearch/ergvein(retractable)
Uploaded by NCrashed at 2020-11-26T16:39:05Z
Distributions
Downloads 986 total (12 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for reflex-dom-retractable-0.1.7.0

[back to package description]

Small library that implements "back" button feature for reflex-dom widgets. The core idea of the library is to have reusable widget that maintains history of switches and is decoupled from actual implementation of switching widgets.

The library doesn't use platform specific parts like connection to Android system back button or browser back button, but provides functions to bind them into your retractable frontend.

Example of usage:

import Control.Monad
import Reflex.Dom
import Reflex.Dom.Retractable

main :: IO ()
main = mainWidget $ runRetract frontend

frontend :: (MonadWidget t m, MonadRetract t m) => m ()
frontend = void $ retractStack $ pageA 42

pageA :: (MonadWidget t m, MonadRetract t m) => Int -> m ()
pageA n = do
   e <- button "Go page B"
   void $ nextWidget $ ffor e $ const Retractable {
       retractableNext = pageB $ n + 1
     , retractablePrev = Just $ pure $ pageA n
     }

pageB :: (MonadWidget t m, MonadRetract t m) => Int -> m ()
pageB n = do
  e <- button "Go page A"
  void $ nextWidget $ ffor e $ const  Retractable {
       retractableNext = pageA $ n + 1
     , retractablePrev = Just $ pure $ pageB n
     }