-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#58] move changed events plugin to use-events libs
- Loading branch information
Showing
7 changed files
with
2,390 additions
and
3,210 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,35 @@ | ||
import { storeToRefs } from "pinia"; | ||
import type { Ref } from "vue"; | ||
import type { ServerEvent, NormalizedEvent } from '../../types'; | ||
import { normalizeUnknownEvent } from "./normalize-unknown-event"; | ||
import { useEventsPlugin, type TUseEventsPluginData } from "./use-events-plugin"; | ||
import type { TCachedEventsEmptyMap, TEventsGroup } from "~/stores/cached-ids"; | ||
import { useCachedIdsStore } from "~/stores/cached-ids"; | ||
|
||
type TUseEvents = () => { | ||
normalizeUnknownEvent: (event: ServerEvent<unknown>) => NormalizedEvent<unknown> | ||
events: TUseEventsPluginData | ||
cachedEvents: { | ||
idsByType: Ref<TCachedEventsEmptyMap>; | ||
stopUpdatesByType: (type: TEventsGroup) => void | ||
runUpdatesByType: (type: TEventsGroup) => void | ||
} | ||
} | ||
|
||
export const useEvents: TUseEvents = () => ({ | ||
normalizeUnknownEvent, | ||
events: useEventsPlugin() | ||
}) | ||
export const useEvents: TUseEvents = () => { | ||
const cachedIdsStore = useCachedIdsStore(); | ||
|
||
const { | ||
cachedIds, | ||
} = storeToRefs(cachedIdsStore) | ||
|
||
return { | ||
normalizeUnknownEvent, | ||
events: useEventsPlugin(), | ||
cachedEvents: { | ||
idsByType: cachedIds as unknown as Ref<TCachedEventsEmptyMap>, | ||
stopUpdatesByType: cachedIdsStore.setByType, | ||
runUpdatesByType: cachedIdsStore.removeByType, | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.