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).
Re-exports from Queue.Types
#Queue Source
class Queue (queue :: Row SCOPE -> Type -> Type) where
Represents an un-indexed queue - such that identifying handlers is not supported.
Members
putMany :: forall t rw a. Traversable t => queue (write :: WRITE | rw) a -> t a -> Effect Unit
popMany :: forall rw a. queue (write :: WRITE | rw) a -> Int -> Effect (Array a)
Pops as many values as indicated off the stack of pending values, if any, in the reverse order they were added - i.e. youngest first.
takeMany :: forall rw a. queue (write :: WRITE | rw) a -> Int -> Effect (Array a)
Pops as many values as indicated off the stack of pending values, if any, in the same order they were added - i.e. oldest first.
takeAll :: forall rw a. queue (write :: WRITE | rw) a -> Effect (Array a)
Equivalent to
length q >>= takeMany q
, but without the overhead.on :: forall rw a. queue (read :: READ | rw) a -> Handler a -> Effect Unit
Assign a handler to capture queue events
once :: forall a rw. queue (read :: READ | rw) a -> Handler a -> Effect Unit
Removes a handler after first run
del :: forall rw a. queue (read :: READ | rw) a -> Effect Unit
read :: forall rw a. queue rw a -> Effect (Array a)
length :: forall rw a. queue rw a -> Effect Int
#draw Source
draw :: forall queue a rw. Queue queue => queue (read :: READ | rw) a -> Aff a
Pull the next asynchronous value out of a queue. Doesn't affect existing handlers (they will all receive the value as well). If this action is canceled, all handlers will be removed from the queue, because this interface is un-indexed.
Pushes multiple values on the stack of pending values, or traverses through the handler(s).