import mitt from 'mitt'const emitter = mitt()// listen to an eventemitter.on('foo', e => console.log('foo', e) )// listen to all eventsemitter.on('*', (type, e) => console.log(type, e) )// fire an eventemitter.emit('foo', { a: 'b' })// clearing all eventsemitter.all.clear()// working with handler references:function onFoo() {}emitter.on('foo', onFoo) // listenemitter.off('foo', onFoo) // unlisten
Hey, my name is Ramu Narasinga. I study large open-source projects and create content about their codebase architecture and best practices, sharing it through articles, videos.
Configure features such as Changesets, Supabase auth in your Next.js project usingThink Throo CLI.