Module

Zeta

Package
purescript-zeta
Repository
athanclark/purescript-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 Source

newtype Signal (rw :: Row SCOPE) a

Constructors

Instances

#subscribe Source

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

Add a subscribers to the set

#subscribeLight Source

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

Subscribe without invoking an initial call of the handler

#subscribeDiff Source

subscribeDiff :: forall a rw. 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 Source

subscribeDiffLight :: forall a rw. 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 Source

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

Publish a message to the set of subscribers

#setDiff Source

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 Source

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

Gets the last message published to the subscribers

#clear Source

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

Removes all subscribers

#make Source

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

Create a signal with a starting value