Module

IxQueue

Queues with an indexed mapping of handlers - this is useful for sending messages to a set of recipients, either discriminately or via broadcast, where removing them individually from the queue is also necessary. This could be useful in interfaces where the set of listening handlers is unknown and dynamic, mimicking global access to updated values.

#IxQueue

newtype IxQueue (rw :: Row SCOPE) a

Constructors

Instances

#new

new :: forall a. Effect (IxQueue (read :: READ, write :: WRITE) a)

#put

put :: forall a rw. IxQueue (write :: WRITE | rw) a -> String -> a -> Effect Unit

Supply a single input to the indexed queue.

#putMany

putMany :: forall a rw t. Traversable t => IxQueue (write :: WRITE | rw) a -> String -> t a -> Effect Unit

Application policy is such that the inputs are stored in the named handler's "pending" values,

#pop

pop :: forall a rw. IxQueue (write :: WRITE | rw) a -> String -> Effect (Maybe a)

#popMany

popMany :: forall a rw. IxQueue (write :: WRITE | rw) a -> String -> Int -> Effect (Array a)

Removes as many locally pending inputs for a specific key, in the order of youngest to oldest.

#broadcast

broadcast :: forall a rw. IxQueue (write :: WRITE | rw) a -> a -> Effect Unit

#broadcastMany

broadcastMany :: forall a rw t. Traversable t => IxQueue (write :: WRITE | rw) a -> t a -> Effect Unit

#broadcastExcept

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

#broadcastManyExcept

broadcastManyExcept :: forall a rw t. Traversable t => IxQueue (write :: WRITE | rw) a -> Array String -> t a -> Effect Unit

Application policy is such that the inputs will be applied uniformly to all handlers, sorted by

#on

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

Application policy is such that the globally pending inputs will be extracted and applied

#once

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

Apply a handler to a specific index that deletes itself after being run, via broadcast or

#draw

draw :: forall rw a. IxQueue (read :: READ | rw) a -> String -> Aff a

Pull the next asynchronous value out of a queue. Doesn't affect existing handlers (they will all receive the value as well). Canceling this action will remove the handler identified by the key.

#readBroadcast

readBroadcast :: forall a rw. IxQueue rw a -> Effect (Array a)

Read only broadcast pending values (if any), without removing them from the queue.

#read

read :: forall a rw. IxQueue rw a -> String -> Effect (Array a)

Read all pending values (if any) for a specific index, without removing them from the queue.

#takeBroadcast

takeBroadcast :: forall a rw. IxQueue (write :: WRITE | rw) a -> Effect (Maybe a)

#takeBroadcastMany

takeBroadcastMany :: forall a rw. IxQueue (write :: WRITE | rw) a -> Int -> Effect (Array a)

Removes only the globally pending inputs, oldest to youngest

#takeBroadcastAll

takeBroadcastAll :: forall a rw. IxQueue (write :: WRITE | rw) a -> Effect (Array a)

Removes only the globally pending inputs

#popBroadcast

popBroadcast :: forall a rw. IxQueue (write :: WRITE | rw) a -> Effect (Maybe a)

#popBroadcastMany

popBroadcastMany :: forall a rw. IxQueue (write :: WRITE | rw) a -> Int -> Effect (Array a)

Removes only the globally pending inputs, oldest to youngest

#take

take :: forall a rw. IxQueue (write :: WRITE | rw) a -> String -> Effect (Maybe a)

#takeMany

takeMany :: forall a rw. IxQueue (write :: WRITE | rw) a -> String -> Int -> Effect (Array a)

Removes as many locally pending inputs for a specific key, in the order of oldest to youngest.

#takeAll

takeAll :: forall a rw. IxQueue (write :: WRITE | rw) a -> String -> Effect (Array a)

Removes locally pending inputs for a specific key

#del

del :: forall a rw. IxQueue (read :: READ | rw) a -> String -> Effect Boolean

Unregisters a handler, returns whether one existed

#clear

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

Removes all handlers, but preserves pending data

#drain

drain :: forall a rw. IxQueue (read :: READ | rw) a -> String -> Effect Unit

Applies a nullary named handler, to remove any globally pending data

#length

length :: forall a rw. IxQueue rw a -> String -> Effect Int

#lengthBroadcast

lengthBroadcast :: forall a rw. IxQueue rw a -> Effect Int

Re-exports from Queue.Types

#WRITE

data WRITE :: SCOPE

#SCOPE

data SCOPE

#READ

data READ :: SCOPE

#Handler

type Handler a = a -> Effect Unit

#QueueScope

class QueueScope (q :: Row SCOPE -> Type -> Type) 

Modules