Skip to content

Commit

Permalink
Fixed #1826 - Remove mitt event bus
Browse files Browse the repository at this point in the history
  • Loading branch information
tugcekucukoglu committed Nov 24, 2021
1 parent 7683c44 commit 64c5eee
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 22 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
"gulp-rename": "^2.0.0",
"gulp-uglify": "^3.0.2",
"gulp-uglifycss": "^1.0.6",
"mitt": "^2.1.0",
"primeflex": "2.0.0",
"primeicons": "5.0.0",
"prismjs": "^1.15.0",
Expand Down
3 changes: 3 additions & 0 deletions src/components/confirmationeventbus/ConfirmationEventBus.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import EventBus from '../utils/EventBus';

export default EventBus();
1 change: 1 addition & 0 deletions src/components/confirmationeventbus/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './ConfirmationEventBus';
2 changes: 2 additions & 0 deletions src/components/confirmationeventbus/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
'use strict';
module.exports = require('./ConfirmationEventBus.js');
4 changes: 0 additions & 4 deletions src/components/confirmationservice/ConfirmationEventBus.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/components/confirmationservice/ConfirmationService.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ConfirmationEventBus from './ConfirmationEventBus';
import ConfirmationEventBus from '../confirmationeventbus/ConfirmationEventBus';

const ConfirmationService = {
install: (Vue) => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/confirmdialog/ConfirmDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</template>

<script>
import ConfirmationEventBus from '../confirmationservice/ConfirmationEventBus';
import ConfirmationEventBus from '../confirmationeventbus/ConfirmationEventBus';
import Dialog from '../dialog/Dialog';
import Button from '../button/Button';
import DomHandler from '../utils/DomHandler';
Expand Down
2 changes: 1 addition & 1 deletion src/components/confirmpopup/ConfirmPopup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</template>

<script>
import ConfirmationEventBus from '../confirmationservice/ConfirmationEventBus';
import ConfirmationEventBus from '../confirmationeventbus/ConfirmationEventBus';
import ConnectedOverlayScrollHandler from '../utils/ConnectedOverlayScrollHandler';
import DomHandler from '../utils/DomHandler';
import Button from '../button/Button';
Expand Down
29 changes: 29 additions & 0 deletions src/components/utils/EventBus.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
export default function () {
const allHandlers = new Map();

return {
on(type, handler) {
let handlers = allHandlers.get(type);
if (!handlers)
handlers = [handler];
else
handlers.push(handler);

allHandlers.set(type, handlers);
},

off(type, handler) {
let handlers = allHandlers.get(type);
if (handlers) {
handlers.splice(handlers.indexOf(handler) >>> 0, 1);
}
},

emit(type, evt) {
let handlers = allHandlers.get(type);
if (handlers) {
handlers.slice().map((handler) => { handler(evt);});
}
}
};
}
8 changes: 1 addition & 7 deletions src/views/confirmdialog/ConfirmDialogDoc.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@
<div class="content-section documentation">
<TabView>
<TabPanel header="Documentation">
<h5>Mitt EventBus</h5>
<p>ConfirmDialog requires <a href="https://www.npmjs.com/package/mitt">Mitt</a>, a tiny 200b EventBus implementation.</p>
<CodeHighlight>
npm install mitt --save
</CodeHighlight>

<h5>ConfirmationService</h5>
<p>ConfirmDialog is controlled via the <i>ConfirmationService</i> that needs to be installed globally before the application
instance is created.</p>
Expand Down Expand Up @@ -212,7 +206,7 @@ export default {
</div>

<h5>Dependencies</h5>
<p>Mitt.</p>
<p>None.</p>
</TabPanel>

<TabPanel header="Source">
Expand Down
8 changes: 1 addition & 7 deletions src/views/confirmpopup/ConfirmPopupDoc.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@
<div class="content-section documentation">
<TabView>
<TabPanel header="Documentation">
<h5>Mitt EventBus</h5>
<p>ConfirmPopup requires <a href="https://www.npmjs.com/package/mitt">Mitt</a>, a tiny 200b EventBus implementation.</p>
<CodeHighlight>
npm install mitt --save
</CodeHighlight>

<h5>ConfirmationService</h5>
<p>ConfirmPopup is controlled via the <i>ConfirmationService</i> that needs to be installed globally before the application
instance is created.</p>
Expand Down Expand Up @@ -226,7 +220,7 @@ export default {
</div>

<h5>Dependencies</h5>
<p>Mitt.</p>
<p>None.</p>
</TabPanel>

<TabPanel header="Source">
Expand Down

0 comments on commit 64c5eee

Please sign in to comment.