Module

IxZeta

Package
purescript-zeta
Repository
athanclark/purescript-zeta

Indexed signals are similar to normal signals in that they represent a single value at all times, and can have a set of handlers that react to the value's change. However, indexed signals also allow for distinguished values for each handler if necessary (where handlers and these indexed values are indexed by a string). Updating a value for a signal can also be indexed, so the change is only reflected to that one handler. Likewise, you can broadcast the update. IxSignals could be useful for many dynamic handlers that need to listen to a shared value - for instance, the window size, so UI components can react a 'la responsive design at their own individual volition, while allowing the handler to be unregistered when the user interface component unmounts.

#IxSignal Source

newtype IxSignal (rw :: Row SCOPE) a

Constructors

Instances

#subscribe Source

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

Add a handler to the signal, and fire on the current value

#subscribeLight Source

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

Add a handler without an initial fire

#subscribeDiff Source

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

Add a handler and fire initially, but only fire when the value changes

#subscribeDiffLight Source

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

Add a handler, but only fire when the value changes

#subscribeWithKey Source

subscribeWithKey :: forall a rw. String -> (String -> Handler a) -> IxSignal (read :: READ | rw) a -> Effect Unit

Add a subscriber to the set, removing and using a specific named value if it exists

#subscribeWithKeyLight Source

subscribeWithKeyLight :: forall a rw. String -> (String -> Handler a) -> IxSignal (read :: READ | rw) a -> Effect Unit

Add a subscriber to the set, without applying a value first. Deletes specific indexed named value, if it exists.

#subscribeWithKeyDiff Source

subscribeWithKeyDiff :: forall a rw. Eq a => String -> (String -> Handler a) -> IxSignal (read :: READ | rw) a -> Effect Unit

Only respond to changes in signal's value, not submissions in total

#subscribeWithKeyDiffLight Source

subscribeWithKeyDiffLight :: forall a rw. Eq a => String -> (String -> Handler a) -> IxSignal (read :: READ | rw) a -> Effect Unit

Like subscribeIxWithKeyDiff, but without an initial firing

#set Source

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

Publish a message to the set of subscribers

#setExcept Source

setExcept :: forall a rw. Array String -> a -> IxSignal (write :: WRITE | rw) a -> Effect Unit

#setIx Source

setIx :: forall a rw. a -> String -> IxSignal (write :: WRITE | rw) a -> Effect Unit

Set a distinguished value for the index, storing if a subscriber is absent

#setDiff Source

setDiff :: forall a. Eq a => a -> IxSignal (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

#setExceptDiff Source

setExceptDiff :: forall a. Eq a => Array String -> a -> IxSignal (read :: READ, write :: WRITE) a -> Effect Unit

#setIxDiff Source

setIxDiff :: forall a. Eq a => a -> String -> IxSignal (read :: READ, write :: WRITE) a -> Effect Unit

#get Source

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

Gets the last message published to the subscribers

#getIx Source

getIx :: forall a rw. String -> IxSignal (read :: READ | rw) a -> Effect a

Attempts to get the last named value, else use the global one.

#clearSubscribers Source

clearSubscribers :: forall a rw. IxSignal (read :: READ | rw) a -> Effect Unit

Removes all subscribers

#clearIndividual Source

clearIndividual :: forall a rw. IxSignal (read :: READ | rw) a -> Effect Unit

Removes all individual

#clear Source

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

Removes all from both

#deleteSubscriber Source

deleteSubscriber :: forall a rw. String -> IxSignal (read :: READ | rw) a -> Effect Unit

Removes a subscriber

#deleteIndividual Source

deleteIndividual :: forall a rw. String -> IxSignal (read :: READ | rw) a -> Effect Unit

Removes an individual value

#delete Source

delete :: forall a rw. String -> IxSignal (read :: READ | rw) a -> Effect Unit

Removes both

#make Source

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

Create a signal with a starting value

#ixSignalToSignal Source

ixSignalToSignal :: forall a rw. IxSignal (read :: READ | rw) a -> String -> Effect (Signal (read :: READ, write :: WRITE) a)