Skip to content

Commit b1cb138

Browse files
authored
Added back Signal.subscribe, and American spelling (urgh!) (#5)
1 parent 5f0274a commit b1cb138

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

src/Wire/Event.purs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ import Unsafe.Reference (unsafeRefEq)
2020
import Wire.Event.Queue as Queue
2121

2222
newtype Event a
23-
= Event (Subscriber a -> Effect Canceller)
23+
= Event (Subscriber a -> Effect Canceler)
2424

2525
type Subscriber a
2626
= a -> Effect Unit
2727

28-
type Canceller
28+
type Canceler
2929
= Effect Unit
3030

3131
create :: forall a. Effect { event :: Event a, push :: a -> Effect Unit, cancel :: Effect Unit }
@@ -44,10 +44,10 @@ create = do
4444
Ref.modify_ (Array.deleteBy unsafeRefEq subscriber) subscribers
4545
pure { event, push: queue.push, cancel: queue.kill }
4646

47-
makeEvent :: forall a. (Subscriber a -> Effect Canceller) -> Event a
47+
makeEvent :: forall a. (Subscriber a -> Effect Canceler) -> Event a
4848
makeEvent = Event
4949

50-
subscribe :: forall a. Event a -> Subscriber a -> Effect Canceller
50+
subscribe :: forall a. Event a -> Subscriber a -> Effect Canceler
5151
subscribe (Event event) = event
5252

5353
filter :: forall a. (a -> Boolean) -> Event a -> Event a
@@ -114,7 +114,7 @@ fromFoldable xs =
114114
liftEffect do emit x
115115
Aff.delay (Milliseconds 0.0)
116116
pure do
117-
Aff.launchAff_ do Aff.killFiber (Aff.error "cancelled") fiber
117+
Aff.launchAff_ do Aff.killFiber (Aff.error "canceled") fiber
118118

119119
range :: Int -> Int -> Event Int
120120
range start end =
@@ -131,7 +131,7 @@ range start end =
131131
pure (Done unit)
132132
fiber <- Aff.launchAff do tailRecM go start
133133
pure do
134-
Aff.launchAff_ do Aff.killFiber (Aff.error "cancelled") fiber
134+
Aff.launchAff_ do Aff.killFiber (Aff.error "canceled") fiber
135135
where
136136
step = if start < end then 1 else -1
137137

src/Wire/Event/Time.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ interval spacing = do
3535
Aff.delay ms
3636
liftEffect do emit unit
3737
pure do
38-
Aff.launchAff_ do Aff.killFiber (Aff.error "cancelling") fiber
38+
Aff.launchAff_ do Aff.killFiber (Aff.error "canceling") fiber
3939

4040
timer :: forall offset spacing. Duration offset => Duration spacing => offset -> spacing -> Event Unit
4141
timer offset spacing = delay offset do pure unit <|> interval spacing

src/Wire/Signal.purs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module Wire.Signal where
33
import Prelude
44
import Effect (Effect)
55
import Effect.Ref as Ref
6-
import Wire.Event (Event)
6+
import Wire.Event (Canceler, Event, Subscriber)
77
import Wire.Event as Event
88

99
newtype Signal a
@@ -33,6 +33,9 @@ create init = do
3333
signal = Signal { event: event', read: read', write: write', modify: modify' }
3434
pure { signal, cancel: inner.cancel }
3535

36+
subscribe :: forall a. Signal a -> Subscriber a -> Effect Canceler
37+
subscribe (Signal s) = Event.subscribe s.event
38+
3639
event :: forall a. Signal a -> Event a
3740
event (Signal s) = s.event
3841

0 commit comments

Comments
 (0)