-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
122 additions
and
62 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
import { useSyncExternalStore } from 'use-sync-external-store/shim'; | ||
|
||
var useSnapshot = function useSnapshot(state) { | ||
return useSyncExternalStore(state.subscribe, state.get, state.get); | ||
var useSnapshot = function useSnapshot(_ref) { | ||
var subscribe = _ref.subscribe, | ||
get = _ref.get; | ||
return useSyncExternalStore(subscribe, get, get); | ||
}; | ||
|
||
export { useSnapshot }; |
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,14 +1,26 @@ | ||
var reduxDevtools = function reduxDevtools(_ref, config) { | ||
var get = _ref.get, | ||
subscribe = _ref.subscribe; | ||
if (typeof window === 'undefined' || !window.__REDUX_DEVTOOLS_EXTENSION__) return; | ||
var devtools = window.__REDUX_DEVTOOLS_EXTENSION__.connect({ | ||
name: config == null ? void 0 : config.key | ||
}); | ||
devtools.init(get()); | ||
subscribe(function () { | ||
return devtools.init(get()); | ||
var reduxDevtools = function reduxDevtools(_temp) { | ||
var _ref = _temp === void 0 ? {} : _temp, | ||
name = _ref.name; | ||
var devtoolsExt; | ||
if (typeof window === 'undefined' || !(devtoolsExt = window.__REDUX_DEVTOOLS_EXTENSION__)) return function () { | ||
/*do nothing*/ | ||
}; | ||
var devtools = devtoolsExt.connect({ | ||
name: name | ||
}); | ||
var mergedState = {}; | ||
return function (_ref2, config) { | ||
var get = _ref2.get, | ||
subscribe = _ref2.subscribe; | ||
var key = config == null ? void 0 : config.key; | ||
if (!key) throw new Error('[reactish-state] state should be provided with a string `key` in the config object when the `reduxDevtools` plugin is used.'); | ||
var updateState = function updateState() { | ||
mergedState[key] = get(); | ||
devtools.init(mergedState); | ||
}; | ||
updateState(); | ||
subscribe(updateState); | ||
}; | ||
}; | ||
|
||
export { reduxDevtools }; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
import type { Middleware } from '../common'; | ||
declare const reduxDevtools: Middleware; | ||
declare type ReduxDevtools = (options?: { | ||
name?: string; | ||
}) => Middleware; | ||
declare const reduxDevtools: ReduxDevtools; | ||
export { reduxDevtools }; |
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,6 @@ | ||
import type { Plugin } from '../common'; | ||
declare const reduxDevtools: Plugin; | ||
declare type ReduxDevtools = (options?: { | ||
name?: string; | ||
}) => Plugin; | ||
declare const reduxDevtools: ReduxDevtools; | ||
export { reduxDevtools }; |
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,3 @@ | ||
import type { Reactish } from '../common'; | ||
declare const useSnapshot: <T>(state: Reactish<T>) => T; | ||
declare const useSnapshot: <T>({ subscribe, get }: Reactish<T>) => T; | ||
export { useSnapshot }; |