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 ]

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


[Skip to Readme]
Versions [faq] 0.1.0.0
Change log CHANGELOG.md
Dependencies base (>=4.7 && <4.12), containers (>=0.5 && <0.7), jsaddle (==0.9.*), mtl (>=2.1 && <2.3), reflex (==0.6.*), reflex-dom (==0.5.*) [details]
License MIT
Copyright 2019 Investment Solutions AG
Author Anton Gushcha, Aminion, Vladimir Krutkin, Levon Oganyan
Maintainer Anton Gushcha <ncrashed@protonmail.com>, Vladimir Krutkin <krutkinvs@gmail.com>
Revised Revision 2 made by NCrashed at Sun Oct 13 12:51:26 UTC 2019
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 Sat Oct 12 23:40:29 UTC 2019
Distributions NixOS:0.1.0.0
Downloads 58 total (15 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs uploaded by user
Build status unknown [no reports yet]

Modules

[Index]

Downloads

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

For package maintainers and hackage trustees


Readme for reflex-dom-retractable-0.1.0.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
     }