Module

IxZeta

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

newtype IxSignal (rw :: Row SCOPE) a

Constructors

Instances

#subscribe

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

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

#subscribeLight

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

Add a handler without an initial fire

#subscribeDiff

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

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

Add a handler, but only fire when the value changes

#subscribeWithKey

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

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

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

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

Like subscribeIxWithKeyDiff, but without an initial firing

#set

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

Publish a message to the set of subscribers

#setExcept

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

#setIx

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

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

#setDiff

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

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

#setIxDiff

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

#get

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

Gets the last message published to the subscribers

#getIx

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

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

#clearSubscribers

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

Removes all subscribers

#clearIndividual

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

Removes all individual

#clear

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

Removes all from both

#deleteSubscriber

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

Removes a subscriber

#deleteIndividual

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

Removes an individual value

#delete

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

Removes both

#make

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

Create a signal with a starting value

#ixSignalToSignal

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

Modules