Skip to content

Commit ae597e9

Browse files
committed
Change README
1 parent 01847b6 commit ae597e9

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

README.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
A [`marionette`](https://github.com/thought2/purescript-marionette) renderer for [`react-basic-hooks`](https://github.com/megamaddu/purescript-react-basic-hooks). Provides an easy to use `useMarionette` hook.
44

5+
If you're using `react-basic-hooks` but you like the way state is handled in `halogen` components this library may be interesting for you.
56

67
## Documentation
78

@@ -22,7 +23,34 @@ spago install react-basic
2223
2324
```
2425

25-
## Example
26+
## Short Example
27+
28+
```hs
29+
type State = Int
30+
type Msg = CountUp | Done
31+
32+
control = case _ of
33+
CountUp -> do
34+
modify_ (_ + 1)
35+
liftAff $ delay (Milliseconds 1000.0)
36+
modify_ (_ + 1)
37+
sendMsg Done
38+
Done -> pure unit
39+
40+
mkApp :: Component {}
41+
mkApp = component "App" \_ -> React.do
42+
state /\ act <- useMarionette
43+
{ initialState: 0
44+
, controller: mkController myControl
45+
}
46+
pure $
47+
R.div'
48+
[ R.div' [ text $ show state ]
49+
, R.button { onClick: handler_ $ act CountUp }
50+
]
51+
```
52+
53+
## Full Examples
2654

2755
You can run the examples in this repo with:
2856

0 commit comments

Comments
 (0)