Module

Queue.Types

Package
purescript-queue
Repository
athanclark/purescript-queue

#SCOPE Source

data SCOPE :: Type

#READ Source

data READ :: SCOPE

#WRITE Source

data WRITE :: SCOPE

#Handler Source

type Handler a = a -> Effect Unit

#QueueScope Source

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

Members

#QueueExtra Source

class QueueExtra (queue :: Row SCOPE -> Type -> Type)  where

Members

#Queue Source

class Queue (queue :: Row SCOPE -> Type -> Type)  where

Represents an un-indexed queue - such that identifying handlers is not supported.

Members

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

    Create a new, empty queue.

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

    Pushes multiple values on the stack of pending values, or traverses through the handler(s).

  • 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

    Removes all handlers from the queue, without affecting the cache.

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

    Observes the values in the queue without deleting them.

  • length :: forall rw a. queue rw a -> Effect Int

    Length of the cache.

#put Source

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

Put only one event.

#pop Source

pop :: forall queue rw a. Queue queue => queue (write :: WRITE | rw) a -> Effect (Maybe a)

Pop the latest added event.

#take Source

take :: forall queue rw a. Queue queue => queue (write :: WRITE | rw) a -> Effect (Maybe a)

Take the first added event.

#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.

#drain Source

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

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