Skip to content

Commit

Permalink
Fixed #1040 - Remove mitt
Browse files Browse the repository at this point in the history
  • Loading branch information
cagataycivici committed Mar 2, 2021
1 parent 72148cb commit d51cc96
Show file tree
Hide file tree
Showing 25 changed files with 52 additions and 68 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
"gulp-rename": "^1.2.2",
"gulp-uglify": "^1.5.3",
"gulp-uglifycss": "^1.0.6",
"mitt": "^2.1.0",
"node-sass": "^4.12.0",
"primeflex": "2.0.0",
"primeicons": "4.1.0",
Expand Down
2 changes: 1 addition & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import AppTopBar from '@/AppTopBar.vue';
import AppMenu from '@/AppMenu.vue';
import AppFooter from '@/AppFooter.vue';
import AppConfigurator from '@/AppConfigurator.vue';
import EventBus from '@/EventBus';
import EventBus from '@/AppEventBus';
export default {
data() {
Expand Down
2 changes: 1 addition & 1 deletion src/AppConfigurator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@
</template>

<script>
import EventBus from '@/EventBus';
import EventBus from '@/AppEventBus';
export default {
props: {
Expand Down
3 changes: 3 additions & 0 deletions src/AppEventBus.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import {EventBus} from 'primevue/utils';

export default EventBus();
3 changes: 0 additions & 3 deletions src/EventBus.js

This file was deleted.

5 changes: 2 additions & 3 deletions src/components/confirmationeventbus/ConfirmationEventBus.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import mitt from 'mitt';
const EventBus = mitt();
import {EventBus} from 'primevue/utils';

export default EventBus;
export default EventBus();
5 changes: 2 additions & 3 deletions src/components/terminalservice/TerminalService.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import mitt from 'mitt';
const TerminalService = mitt();
import {EventBus} from 'primevue/utils';

export default TerminalService;
export default EventBus();
5 changes: 2 additions & 3 deletions src/components/toasteventbus/ToastEventBus.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import mitt from 'mitt';
const EventBus = mitt();
import {EventBus} from 'primevue/utils';

export default EventBus;
export default EventBus();
25 changes: 25 additions & 0 deletions src/components/utils/EventBus.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
export default function handler() {
let eventTarget = document.body.appendChild(document.createComment(''));
let eventListener, eventKey;

return {
on(type, listener, key) {
eventKey = key;
eventListener = function(e) { listener(e.detail); };
eventTarget.addEventListener(type, eventListener);
},
once(type, listener, key) {
eventKey = key;
eventListener = function(e) { listener(e.detail); };
eventTarget.addEventListener(type, eventListener, { once: true });
},
off(type, key) {
if (eventListener && eventKey === key) {
eventTarget.removeEventListener(type, eventListener);
}
},
emit(type, detail) {
eventTarget.dispatchEvent(new CustomEvent(type, { detail }));
}
}
}
3 changes: 2 additions & 1 deletion src/components/utils/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ import ConnectedOverlayScrollHandler from './ConnectedOverlayScrollHandler';
import DomHandler from './DomHandler';
import ObjectUtils from './ObjectUtils';
import UniqueComponentId from './UniqueComponentId';
import EventBus from './EventBus';

export {ConnectedOverlayScrollHandler,DomHandler,ObjectUtils,UniqueComponentId};
export {ConnectedOverlayScrollHandler,DomHandler,ObjectUtils,UniqueComponentId,EventBus};
2 changes: 1 addition & 1 deletion src/views/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@
</template>

<script>
import EventBus from '@/EventBus';
import EventBus from '@/AppEventBus';
export default {
data() {
Expand Down
2 changes: 1 addition & 1 deletion src/views/chart/BarChartDemo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

<script>
import BarChartDoc from './BarChartDoc';
import EventBus from '@/EventBus';
import EventBus from '@/AppEventBus';
export default {
mounted() {
Expand Down
2 changes: 1 addition & 1 deletion src/views/chart/ComboChartDemo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<script>
import ComboChartDoc from './ComboChartDoc';
import EventBus from '@/EventBus';
import EventBus from '@/AppEventBus';
export default {
mounted() {
Expand Down
2 changes: 1 addition & 1 deletion src/views/chart/DoughnutChartDemo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<script>
import DoughnutChartDoc from './DoughnutChartDoc';
import EventBus from '@/EventBus';
import EventBus from '@/AppEventBus';
export default {
mounted() {
Expand Down
2 changes: 1 addition & 1 deletion src/views/chart/LineChartDemo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

<script>
import LineChartDoc from './LineChartDoc';
import EventBus from '@/EventBus';
import EventBus from '@/AppEventBus';
export default {
mounted() {
Expand Down
2 changes: 1 addition & 1 deletion src/views/chart/PieChartDemo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<script>
import PieChartDoc from './PieChartDoc';
import EventBus from '@/EventBus';
import EventBus from '@/AppEventBus';
export default {
mounted() {
Expand Down
2 changes: 1 addition & 1 deletion src/views/chart/PolarAreaChartDemo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<script>
import PolarAreaChartDoc from './PolarAreaChartDoc';
import EventBus from '@/EventBus';
import EventBus from '@/AppEventBus';
export default {
mounted() {
Expand Down
2 changes: 1 addition & 1 deletion src/views/chart/RadarChartDemo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<script>
import RadarChartDoc from './RadarChartDoc';
import EventBus from '@/EventBus';
import EventBus from '@/AppEventBus';
export default {
mounted() {
Expand Down
9 changes: 1 addition & 8 deletions src/views/confirmdialog/ConfirmDialogDoc.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +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>
<pre v-code><code>
npm install mitt --save

</code></pre>

<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 @@ -247,7 +240,7 @@ export default {
</div>

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

<TabPanel header="Source">
Expand Down
9 changes: 1 addition & 8 deletions src/views/confirmpopup/ConfirmPopupDoc.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +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>
<pre v-code><code>
npm install mitt --save

</code></pre>

<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 @@ -247,7 +240,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/liveeditor/LiveEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,7 @@ export const router = createRouter({
})
}
if(this.toastService) {
extDependencies['mitt'] = "^2.1.0";
if(this.toastService) {
imports += `import Toast from "primevue/toast";
import ToastService from "primevue/toastservice";
`;
Expand All @@ -242,10 +240,6 @@ import ToastService from "primevue/toastservice";
`;
}
if(this.terminalService) {
extDependencies['mitt'] = "^2.1.0";
}
if(name !== 'ToastDemo' && name !== 'TooltipDemo' && name !== 'RippleDemo' && name !== 'FloatLabelDemo' && name !== 'InputGroupDemo' && name !== 'InvalidDemo' && name !== 'FormLayoutDemo') {
element += `app.component("${name.slice(0, -4)}", ${name.slice(0, -4)});`;
}
Expand Down
4 changes: 0 additions & 4 deletions src/views/setup/Setup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,6 @@ dependencies: {
<td>PrimeFlex</td>
<td>DataView</td>
</tr>
<tr>
<td>Toast and Terminal</td>
<td>Mitt</td>
</tr>
</tbody>
</table>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/views/tabview/TabViewDemo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@

<script>
import TabViewDoc from './TabViewDoc';
import EventBus from '@/EventBus';
import EventBus from '@/AppEventBus';
export default {
data() {
Expand Down
9 changes: 1 addition & 8 deletions src/views/terminal/TerminalDoc.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@
<div class="content-section documentation">
<TabView>
<TabPanel header="Documentation">
<h5>Mitt EventBus</h5>
<p>Terminal requires <a href="https://www.npmjs.com/package/mitt">Mitt</a>, a tiny 200b EventBus implementation.</p>
<pre v-code><code>
npm install mitt --save

</code></pre>

<h5>Import</h5>
<pre v-code.script><code>
import Terminal from 'primevue/terminal';
Expand Down Expand Up @@ -130,7 +123,7 @@ export default {
</div>

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

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

</code></pre>

<h5>ToastService</h5>
<p>Toast messages are dynamically created using a <i>ToastService</i> that needs to be installed globally before the application
instance is created.</p>
Expand Down Expand Up @@ -270,7 +263,7 @@ this.$toast.add({severity:'success', summary: 'Specific Message', group: 'mykey'
</div>

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

<TabPanel header="Source">
Expand Down

0 comments on commit d51cc96

Please sign in to comment.