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, 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 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 t rw a. 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 Source

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

#popMany Source

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

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

#broadcastMany Source

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

#broadcastExcept Source

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

#broadcastManyExcept Source

broadcastManyExcept :: forall t rw a. 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 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). Canceling this action will remove the handler identified by the key.

#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 (Maybe a)

#takeBroadcastMany Source

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

Removes only the globally pending inputs, oldest to youngest

#takeBroadcastAll Source

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

Removes only the globally pending inputs

#popBroadcast Source

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

#popBroadcastMany Source

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

Removes only the globally pending inputs, oldest to youngest

#take Source

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

#takeMany Source

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

takeAll :: 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

#length Source

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

#lengthBroadcast Source

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

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