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

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain] [Publish]

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


[Skip to Readme]

Properties

Versions 0.1.0.0, 0.1.3.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.13), 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.7), 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-05-18T02:15:54Z

Modules

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


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