-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from pubpub/new-hooks-api
update: New Hooks API
- Loading branch information
Showing
17 changed files
with
373 additions
and
328 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { UseEffect, UseRef, UseState } from "./store/attrStore"; | ||
import { Hooks, UseDeferredNode, UseReactiveMap } from "./store/types"; | ||
|
||
let currentHooks: null | Hooks = null; | ||
|
||
export const setCurrentHooks = (hooks: Hooks) => { | ||
currentHooks = hooks; | ||
}; | ||
|
||
export const useDeferredNode: UseDeferredNode = (nodeIds, callback) => | ||
currentHooks.useDeferredNode(nodeIds, callback); | ||
|
||
export const useDocumentState: UseReactiveMap = (path, initialState) => | ||
currentHooks.useDocumentState(path, initialState); | ||
|
||
export const useTransactionState: UseReactiveMap = (path, initialState) => | ||
currentHooks.useTransactionState(path, initialState); | ||
|
||
export const useState: UseState = initialValue => currentHooks.useState(initialValue); | ||
export const useEffect: UseEffect = (fn, dependencies) => currentHooks.useEffect(fn, dependencies); | ||
export const useRef: UseRef = initialValue => currentHooks.useRef(initialValue); |
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,3 +1,11 @@ | ||
export * from "./plugin"; | ||
export { getReactedDoc } from "./doc"; | ||
export { addTemporaryIdsToDoc } from "./util"; | ||
export { | ||
useState, | ||
useEffect, | ||
useRef, | ||
useDeferredNode, | ||
useTransactionState, | ||
useDocumentState, | ||
} from "./globalHooks"; |
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.