Skip to content

Commit

Permalink
fix: Use mitt to handle events
Browse files Browse the repository at this point in the history
  • Loading branch information
LautaroPetaccio committed Mar 22, 2024
1 parent 7efcbbc commit e564dab
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 26 deletions.
26 changes: 11 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"decentraland-ui": "^3.49.0",
"deep-equal": "^2.0.5",
"fp-future": "^1.0.1",
"mitt": "^3.0.1",
"prettier": "^2.4.1",
"raw-loader": "^4.0.2",
"react": "^17.0.2",
Expand Down Expand Up @@ -65,8 +66,5 @@
"singleQuote": true,
"printWidth": 120
},
"homepage": "",
"devDependencies": {
"@foxify/events": "^2.1.0"
}
"homepage": ""
}
14 changes: 7 additions & 7 deletions src/lib/babylon/emote.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import EventEmitter from '@foxify/events'
import mitt from 'mitt'
import {
AnimationGroup,
ArcRotateCamera,
Expand Down Expand Up @@ -247,14 +247,14 @@ function createController(animationGroup: AnimationGroup, loop: boolean, sound:

// Temporary typed events.
type Events = {
[PreviewEmoteEventType.ANIMATION_PLAY]: () => unknown
[PreviewEmoteEventType.ANIMATION_PAUSE]: () => unknown
[PreviewEmoteEventType.ANIMATION_LOOP]: () => unknown
[PreviewEmoteEventType.ANIMATION_END]: () => unknown
[PreviewEmoteEventType.ANIMATION_PLAYING]: ({ length }: { length: number }) => unknown
[PreviewEmoteEventType.ANIMATION_PLAY]: void
[PreviewEmoteEventType.ANIMATION_PAUSE]: void
[PreviewEmoteEventType.ANIMATION_LOOP]: void
[PreviewEmoteEventType.ANIMATION_END]: void
[PreviewEmoteEventType.ANIMATION_PLAYING]: { length: number }
}

const events = new EventEmitter<Events>()
const events = mitt<Events>()

// Emit the PreviewEmoteEventType.ANIMATION_PLAYING event with the current playing frame
const emitPlayingEvent = () => {
Expand Down

0 comments on commit e564dab

Please sign in to comment.