@reactive-js/react
Advanced tools
Comparing version
@@ -1,6 +0,5 @@ | ||
import { SideEffect1, Function1, Updater } from "@reactive-js/core/lib/functions"; | ||
import { SideEffect1 } from "@reactive-js/core/lib/functions"; | ||
import { ObservableLike } from "@reactive-js/core/lib/observable"; | ||
import { Option } from "@reactive-js/core/lib/option"; | ||
import { SchedulerLike } from "@reactive-js/core/lib/scheduler"; | ||
import { StateStoreLike } from "@reactive-js/core/lib/stateStore"; | ||
import { StreamableLike } from "@reactive-js/core/lib/streamable"; | ||
@@ -13,2 +12,1 @@ export declare const useObservable: <T>(observable: ObservableLike<T>, scheduler?: SchedulerLike) => Option<T>; | ||
}) => [Option<T>, SideEffect1<TReq>]; | ||
export declare const useSerializedState: <TSerialized, TState>(store: StateStoreLike<TSerialized>, parse: Function1<TSerialized, TState>, serialize: Function1<TState, TSerialized>) => [Option<TState>, SideEffect1<Updater<TState>>]; |
@@ -53,10 +53,1 @@ "use strict"; | ||
}; | ||
const requestMapper = (parse, serialize) => (stateUpdater) => oldStateString => { | ||
const oldState = parse(oldStateString); | ||
const newState = stateUpdater(oldState); | ||
return oldState === newState ? oldStateString : serialize(newState); | ||
}; | ||
exports.useSerializedState = (store, parse, serialize) => { | ||
const mappedStore = react_1.useMemo(functions_1.defer(store, streamable_1.mapReq(requestMapper(parse, serialize)), streamable_1.map(parse)), [store, parse, serialize]); | ||
return exports.useStreamable(mappedStore, { replay: 1 }); | ||
}; |
@@ -8,18 +8,2 @@ "use strict"; | ||
const scheduler_2 = require("scheduler"); | ||
const getScheduler = (priority) => { | ||
switch (priority) { | ||
case scheduler_2.unstable_IdlePriority: | ||
return exports.idlePriority; | ||
case scheduler_2.unstable_ImmediatePriority: | ||
return exports.immediatePriority; | ||
case scheduler_2.unstable_NormalPriority: | ||
return exports.normalPriority; | ||
case scheduler_2.unstable_LowPriority: | ||
return exports.lowPriority; | ||
case scheduler_2.unstable_UserBlockingPriority: | ||
return exports.userBlockingPriority; | ||
default: | ||
throw new Error(); | ||
} | ||
}; | ||
const priorityScheduler = { | ||
@@ -30,8 +14,10 @@ inContinuation: false, | ||
}, | ||
get shouldYield() { | ||
return scheduler_2.unstable_shouldYield(); | ||
}, | ||
schedule(continuation, { priority, delay = 0, }) { | ||
const scheduler = getScheduler(priority); | ||
const callback = () => { | ||
disposable_1.dispose(callbackNodeDisposable); | ||
priorityScheduler.inContinuation = true; | ||
scheduler_1.runContinuation(scheduler, continuation); | ||
scheduler_1.continue$(continuation); | ||
priorityScheduler.inContinuation = false; | ||
@@ -43,7 +29,2 @@ }; | ||
}, | ||
yield({ delay } = { delay: 0 }) { | ||
if (delay > 0 || scheduler_2.unstable_shouldYield()) { | ||
throw new scheduler_1.YieldError(delay); | ||
} | ||
}, | ||
}; | ||
@@ -50,0 +31,0 @@ exports.idlePriority = functions_1.pipe(priorityScheduler, scheduler_1.toSchedulerWithPriority(scheduler_2.unstable_IdlePriority)); |
{ | ||
"name": "@reactive-js/react", | ||
"version": "0.0.38", | ||
"version": "0.0.39", | ||
"keywords": [ | ||
@@ -39,3 +39,3 @@ "asynchronous", | ||
"dependencies": { | ||
"@reactive-js/core": "^0.0.38", | ||
"@reactive-js/core": "^0.0.39", | ||
"react": "^16.11.0", | ||
@@ -71,3 +71,3 @@ "scheduler": "^0.17.0" | ||
}, | ||
"gitHead": "be682ccddb37bc8dfb141b07394866d3b08f4f65" | ||
"gitHead": "a6c0ab3344e0aeeb8ae1ef38153be8eb5dc09560" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
-100%18706
-12.95%320
-15.34%+ Added
- Removed
Updated