Skip to content

Commit

Permalink
fix: fix flash emit (monicahq/chandler#389)
Browse files Browse the repository at this point in the history
  • Loading branch information
asbiin authored Jan 10, 2023
1 parent dd67f3f commit 03f332c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
1 change: 1 addition & 0 deletions resources/js/Pages/API/Partials/ApiTokenManager.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { ref, watch } from 'vue';
import { useForm } from '@inertiajs/inertia-vue3';
import { trans } from 'laravel-vue-i18n';
import { flash } from '@/methods.js';
import useClipboard from 'vue-clipboard3';
import JetActionMessage from '@/Components/Jetstream/ActionMessage.vue';
import JetActionSection from '@/Components/Jetstream/ActionSection.vue';
Expand Down
25 changes: 12 additions & 13 deletions resources/js/methods.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
import Emitter from 'tiny-emitter';
const emitter = new Emitter();
import emitter from 'tiny-emitter/instance';

export default {
/**
* Flash a message.
*
* @param {string} message
* @param {string} level
*/
flash(message, level = 'success') {
this.$emitt('flash', { message, level });
},
/**
* Flash a message.
*
* @param {string} message
* @param {string} level
*/
export const flash = (message, level = 'success') => {
emitter.emit('flash', { message, level });
};

export default {
flash,
$on: (...args) => emitter.on(...args),
$once: (...args) => emitter.once(...args),
$off: (...args) => emitter.off(...args),
$emitt: (...args) => emitter.emit(...args),
};

0 comments on commit 03f332c

Please sign in to comment.