A simple bulletin board for managing channels in an event bus system. This is extracted from closed source code I've been using for a while. It's not feature complete, because I did not need all the features. But as an open-source library I will make time to add all the HOFs in core.async.
I use this setup within integrant keys allowing for a visual way to see how channels are connected. Because of the way core.async manages it's mults, taps, pubs and subs, closing almost all the channels occurs by closing the event bus. I've never bothered to add a close function to this library because the wiring is meant to be immutable. All channels are added and wired at integrant init and not intended to be changed after that. Although if your needs differ. As a plus, mixing this with integrant.repl.state and portal makes it dead simple to reason about what is happening in your system.
A simple bulletin board for managing channels in an event bus system. This is extracted from closed source code I've been using for a while. It's not feature complete, because I did not need all the features. But as an open-source library I will make time to add all the HOFs in core.async. I use this setup within integrant keys allowing for a visual way to see how channels are connected. Because of the way core.async manages it's mults, taps, pubs and subs, closing almost all the channels occurs by closing the event bus. I've never bothered to add a close function to this library because the wiring is meant to be immutable. All channels are added and wired at integrant init and not intended to be changed after that. Although if your needs differ. As a plus, mixing this with integrant.repl.state and portal makes it dead simple to reason about what is happening in your system.
(add-chan! m)(add-chan! bob ch-id)(add-chan! bob ch-id ch)Generic add channel function. If a channel is provided, it will be used. Otherwise, a new channel will be created.
Generic add channel function. If a channel is provided, it will be used. Otherwise, a new channel will be created.
(add-merge! m)(add-merge! bob merge-ident ch-idents)Adds a merge of the supplied channels.
Adds a merge of the supplied channels.
(add-mixer! m)(add-mixer! bob mixer-ident)Adds a mixer and output channel, attaching channels if provided.
Adds a mixer and output channel, attaching channels if provided.
(add-mult! m)(add-mult! bob mult-id src-id)Creates a new mult, links it to it's source and adds it to the bulletin board.
Creates a new mult, links it to it's source and adds it to the bulletin board.
(add-pub! m)(add-pub! bob pub-ident src-ident rule)Adds a pub, linking it to a source, and adds it to the bulletin board.
Adds a pub, linking it to a source, and adds it to the bulletin board.
(add-sub! m)(add-sub! bob sub-ident pub-ident topic)Adds a sub to a pub. Must provide an existing channel.
Adds a sub to a pub. Must provide an existing channel.
(add-tap! m)(add-tap! bob tap-ident mult-ident)(add-tap! bob tap-ident tap-ch mult-ident)Creates a tap, taps it into a mult and adds it to the bulletin board.
Creates a tap, taps it into a mult and adds it to the bulletin board.
(add-to-bob! bob comms)Wires everything into bulletin board. Comms arg is a vector. The order of this vector should be starting with your event-bus. :buses, taps, mults, pubs, subs, merges, consumers. Often nothing bad will happen if you don't do this, but it's good practice because when you don't you may wind up creating a new channel when you'd prefer to use an old one and there's no easy way to troubleshoot that one.
Wires everything into bulletin board. Comms arg is a vector. The order of this vector should be starting with your event-bus. :buses, taps, mults, pubs, subs, merges, consumers. Often nothing bad will happen if you don't do this, but it's good practice because when you don't you may wind up creating a new channel when you'd prefer to use an old one and there's no easy way to troubleshoot that one.
(add-to-mix! m)(add-to-mix! bob chan-ident mixer-ident)(add-to-mix! bob chan-ident mixer-ident toggle-config)Adds a channel to a mix, setting it's config if provided.
Adds a channel to a mix, setting it's config if provided.
(bob! & ms)Wires a channel into the bulletin board.
Wires a channel into the bulletin board.
(dir-add m)(dir-add bob id v)(dir-add bob ln id v)(dir-path-for id)(dir-path-for ln id)(extract-chan-ns id)Takes the channel ns from a channel's coordinates. In the event of nested coordinates, takes the last ns.
Takes the channel ns from a channel's coordinates. In the event of nested coordinates, takes the last ns.
(flattenv thing)Flattens a collection and returns a vector
Flattens a collection and returns a vector
(id->f id)Takes an id and returns the function that creates, wires, and adds it to the bulletin board.
Takes an id and returns the function that creates, wires, and adds it to the bulletin board.
(mute-chan! m)(mute-chan! bob mixer-ident chan-ident)Mutes a channel in a mix.
Mutes a channel in a mix.
(pause-chan! m)(pause-chan! bob mixer-ident chan-ident)Pauses a channel in a mix.
Pauses a channel in a mix.
(solo-chan! m)(solo-chan! bob mixer-ident chan-ident)Solos a channel in a mix.
Solos a channel in a mix.
(subdir-for id)(toggle-chan! m)(toggle-chan! bob mixer-ident chan-ident toggle-config)Changes the mix settings on a channel.
Changes the mix settings on a channel.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |