Skip to content

Commit

Permalink
feat: added composable useEventBus
Browse files Browse the repository at this point in the history
  • Loading branch information
AskeLange committed Feb 8, 2024
1 parent b73b3f8 commit 977f02a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions composables/useEventBus.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export function useEventBus() {
const app = useNuxtApp();

return {
on(event, callback) {
if (typeof callback === 'function') {
app.hook(`limbo:${event}`, callback);
}
},

emit(event, data) {
app.hooks.callHook(`limbo:${event}`, data);
},
};
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@limbo-works/nuxt-core",
"type": "module",
"version": "2.3.0",
"version": "2.4.0",
"main": "./nuxt.config.js",
"scripts": {
"dev": "nuxi prepare & nuxi dev .playground",
Expand Down

0 comments on commit 977f02a

Please sign in to comment.