Module

Zeta

Signals are a dual concept to Queues - they always have a value that may change, while a queue represents transient events. This module defines a lower level interface to a signal - so you can clearly see that registering handlers via subscribe is effectful, as is changing the current value with set.

#Signal

newtype Signal (rw :: Row SCOPE) a

Constructors

Instances

#subscribe

subscribe :: forall rw a. Handler a -> Signal (read :: READ | rw) a -> Effect Unit

Add a subscribers to the set

#subscribeLight

subscribeLight :: forall rw a. Handler a -> Signal (read :: READ | rw) a -> Effect Unit

Subscribe without invoking an initial call of the handler

#subscribeDiff

subscribeDiff :: forall rw a. Eq a => Handler a -> Signal (read :: READ | rw) a -> Effect Unit

Fires the handler on the initial value, and successively only when the value changes with respect to Eq.

#subscribeDiffLight

subscribeDiffLight :: forall rw a. Eq a => Handler a -> Signal (read :: READ | rw) a -> Effect Unit

Does not fire the handler on the initial value - only waits until it changes with respect to Eq.

#set

set :: forall rw a. a -> Signal (write :: WRITE | rw) a -> Effect Unit

Publish a message to the set of subscribers

#setDiff

setDiff :: forall a. Eq a => a -> Signal (read :: READ, write :: WRITE) a -> Effect Unit

Only set the value if it differs from the current one - useful if you don't want each handler individually to attempt diffing

#get

get :: forall rw a. Signal (read :: READ | rw) a -> Effect a

Gets the last message published to the subscribers

#clear

clear :: forall rw a. Signal (read :: READ | rw) a -> Effect Unit

Removes all subscribers

#make

make :: forall a. a -> Effect (Signal (read :: READ, write :: WRITE) a)

Create a signal with a starting value

Modules