Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import AppCommand from "../../commands/AppCommand"
- import { useCallback, useMemo } from "react"
- import { useBus } from "react-bus"
- const useCoreAppFunctions = () => {
- //
- const bus = useBus()
- const nextImage = useCallback(() => {
- //alert("useAppFunctions::nextImage")
- bus.emit(AppCommand.NEXT_IMAGE)
- }, [bus])
- const previousImage = useCallback(() => {
- //alert("useAppFunctions::previousImage")
- bus.emit(AppCommand.PREV_IMAGE)
- }, [bus])
- const functions = useMemo(() => {
- return {
- core: {
- nextImage,
- previousImage,
- },
- }
- }, [nextImage, previousImage])
- const receiver = functions
- const app = {
- functions,
- receiver,
- }
- return app
- }
- export default useAppFunctions
- import {
- CoreAppFunctions,
- CoreAppReceiver,
- default as useCoreAppFunctions,
- } from "@core/features/app/hooks/functions/useCoreAppFunctions"
- // TODO: we'll need to use some memoization if we useBus
- const useAppFunctions = () => {
- //
- const core = useCoreAppFunctions().functions.core
- const foo = (window_id: number) => {
- console.log(`foo: ${window_id}`)
- }
- const test = {
- foo,
- }
- const functions: AppFunctions = {
- core,
- test,
- }
- const receiver = functions
- const app = {
- functions,
- receiver,
- }
- return app
- }
- export default useAppFunctions
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement