cabal-club / cabal-client

interface for writing peer-to-peer chat clients
GNU General Public License v3.0
95 stars 14 forks source link

events for managing cabals #86

Open khubo opened 2 years ago

khubo commented 2 years ago

Currently all events are at cabal level, and there is no events emitted for adding/joining/removing cabal etc. It would be dope if we could have some events for the same at client level. Events on top of my head is:

cblgh commented 2 years ago

thanks for making an issue on this @khubo!

just gonna brainstorm a bit


so we have the client object typically, e.g.

const Client = require("cabal-client")
const client = new Client({/* opts */})

// which is e.g. used to create a cabal
client.createCabal().then(/* more stuff */)

so i guess this proposal would look something like

client.on("leave", ({ key /* anything else? */}) => /* do stuff in the on-leave */)
client.on("join", ({ key }) => ) // currently covered by cb here https://github.com/cabal-club/cabal-client/blob/master/src/client.js#L169
client.on("create" ({ key }) => ) // also covered by cb here https://github.com/cabal-club/cabal-client/blob/master/src/client.js#L169

some other interesting events at the client level:


yeah i like it, i think :) how do you feel about those three additional events?