Skip to content

Commit 6873aa7

Browse files
committed
Fixed module name and updated test
1 parent d4b6b65 commit 6873aa7

File tree

2 files changed

+18
-50
lines changed

2 files changed

+18
-50
lines changed

src/Wire/React.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module Wire.Store.Hooks where
1+
module Wire.React where
22

33
import Prelude
44
import Data.Newtype (class Newtype)

test/Main.purs

Lines changed: 17 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -5,58 +5,26 @@ import Effect (Effect)
55
import Effect.Aff (Milliseconds(..), delay, launchAff_)
66
import Effect.Class (liftEffect)
77
import Effect.Class.Console as Console
8-
import Wire.Signal as Signal
9-
import Wire.Store as Store
10-
import Wire.Store.Atom (Atom)
11-
import Wire.Store.Atom as Atom
12-
import Wire.Store.Selector (Selector)
13-
import Wire.Store.Selector as Selector
14-
15-
main1 :: Effect Unit
16-
main1 = do
17-
Console.log "test:"
18-
let
19-
signal = do
20-
a <- pure 1
21-
b <- pure 2
22-
c <- pure 3
23-
pure (a + b + c)
24-
void $ Signal.subscribe signal Console.logShow
8+
import Wire.React.Class as Atom
9+
import Wire.React.Pure as Pure
10+
import Wire.React.Selector as Selector
2511

2612
main :: Effect Unit
2713
main = do
28-
store <-
29-
Store.empty
30-
# ( Store.withAtom testAtom1
31-
>=> Store.withAtom testAtom2
32-
)
33-
_ <- Signal.subscribe (Selector.build testSelector store).signal Console.logShow
14+
testAtom1 <- Pure.create 2.0
15+
testAtom2 <- Pure.create 100.0
16+
testSelector <-
17+
Selector.create
18+
{ select:
19+
do
20+
test1 <- Selector.select testAtom1
21+
test2 <- Selector.select testAtom2
22+
pure $ test2 / test1
23+
, update: mempty
24+
}
25+
_ <- Atom.subscribe testSelector Console.logShow
3426
launchAff_ do
3527
delay $ Milliseconds 2000.0
36-
liftEffect $ Store.updateAtom 4.0 testAtom1 store
28+
liftEffect $ Atom.modify testAtom1 (const 4.0)
3729
delay $ Milliseconds 5000.0
38-
liftEffect $ Store.updateAtom 50.0 testAtom2 store
39-
40-
testAtom1 :: Atom "test1" Number
41-
testAtom1 = Atom.makePure 2.0
42-
43-
testAtom2 :: Atom "test2" Number
44-
testAtom2 = Atom.makePure 100.0
45-
46-
testSelector ::
47-
forall atoms.
48-
Selector
49-
( test1 :: Number
50-
, test2 :: Number
51-
| atoms
52-
)
53-
Number
54-
testSelector =
55-
Selector.makeSelector
56-
{ select:
57-
do
58-
test1 <- Selector.select testAtom1
59-
test2 <- Selector.select testAtom2
60-
pure $ test2 / test1
61-
, update: mempty
62-
}
30+
liftEffect $ Atom.modify testAtom2 (const 50.0)

0 commit comments

Comments
 (0)