Module

Queue.One

Package
purescript-queue
Repository
athanclark/purescript-queue

Queues with at most one handler - this is useful for sending messages to a single, solitary handler (user interface component, websocket connection, what have you).

#Queue Source

newtype Queue (rw :: Row SCOPE) a

Constructors

Instances

#new Source

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

#put Source

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

Supply a single input to the queue.

#putMany Source

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

Supply many inputs in batch to the queue.

#on Source

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

Assign the handler to the singleton queue.

#once Source

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

Run the handler only once for the next input before unassigning itself.

#draw Source

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

Pull a single asynchronous value out of a queue.

#take Source

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

Take all pending values (if any) from the queue.

#read Source

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

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

#del Source

del :: forall a rw. Queue (read :: READ | rw) a -> Effect Unit

Removes the registered callbacks, if any.

#drain Source

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

Adds a listener that does nothing, and "drains" any pending messages.

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