Module

IxQueue

Package
purescript-queue
Repository
athanclark/purescript-queue

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

#IxQueue Source

newtype IxQueue (rw :: Row SCOPE) a

Constructors

Instances

#new Source

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

#put Source

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

Supply a single input to the indexed queue.

#putMany Source

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

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

#broadcast Source

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

#broadcastMany Source

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

#broadcastExcept Source

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

#broadcastManyExcept Source

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

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

#on Source

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

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

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

#readBroadcast Source

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

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

#read Source

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

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

#takeBroadcast Source

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

Removes only the globally pending inputs

#take Source

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

Removes locally pending inputs for a specific key

#del Source

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

Unregisters a handler, returns whether one existed

#clear Source

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

Removes all handlers, but preserves pending data

#drain Source

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

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

Re-exports from Queue.Types

#WRITE Source

data WRITE :: SCOPE

#READ Source

data READ :: SCOPE

#Handler Source

type Handler a = a -> Effect Unit

#QueueScope Source

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

#SCOPE Source

data SCOPE :: Type