CrossClj

0.2.3 docs

SourceDocs



RECENT
    VARS
    with-receive-channel

    « Index of all namespaces of this project

    User-facing convenience code to assist with Bureaucrat.
    
    macro
    (with-receive-channel [channel queue] & forms)
    Opens a core.async data-receive channel on the given Bureaucrat endpoint for
    the duration of the given forms. Ensures that the queue's listener is
    unregistered after forms with a try...finally.
    
    The first argument is a let-style vector specifying the
    queue-to-channel binding. The first element is the symbol to bind the
    receive channel to; the second argument is the Bureaucrat endpoint to
    derive the binding from.
    
    Example:
    
    (with-receive-channel [ch (get-a-bureaucrat-queue)]
       (println "Got from queue:" (<!! ch)))
    
    Here, (get-a-bureaucrat-queue) is some function that returns a
    Bureaucrat endpoint. The symbol ch will be bound to this endpoint via
    a core.async channel. In the code block, we take a value from the ch
    channel and print it. After our block is done, with-receive-channel
    macro unbinds the channel from the endpoint automatically.
    
    Note that any listener function already attached to the given endpoint
    will be overwritten by using it in this macro.