@exodus/atoms
Advanced tools
Comparing version 3.7.0 to 4.0.0
{ | ||
"name": "@exodus/atoms", | ||
"version": "3.7.0", | ||
"version": "4.0.0", | ||
"main": "src/index.js", | ||
@@ -37,3 +37,3 @@ "author": "Exodus Movement Inc.", | ||
}, | ||
"gitHead": "de75a59d866ea737d6d1698c3c1edd7a44af0295" | ||
"gitHead": "99487e27398623ebf0588233db4f01443c93102d" | ||
} |
import makeConcurrent from 'make-concurrent' | ||
import proxyFreeze from 'proxy-freeze' | ||
import { isEqual } from 'lodash' | ||
import assert from 'minimalistic-assert' | ||
@@ -17,7 +15,3 @@ const withChangeDetection = (listener) => { | ||
try { | ||
await listener(currentValue) | ||
} catch (error) { | ||
console.warn('observer failed', error) | ||
} | ||
await listener(currentValue) | ||
}, | ||
@@ -30,5 +24,3 @@ get called() { | ||
const enforceObservableRules = ({ defaultValue, logger, warnOnSameValueSet = false, ...atom }) => { | ||
assert(!warnOnSameValueSet || logger, 'warnOnSameValueSet specified but no logger supplied') | ||
const enforceObservableRules = ({ defaultValue, logger, ...atom }) => { | ||
// ensure observers get called in series | ||
@@ -56,8 +48,2 @@ const enqueue = makeConcurrent((fn) => fn(), { concurrency: 1 }) | ||
if (warnOnSameValueSet && isEqual(value, await get())) { | ||
logger.warn( | ||
`Atom was called with the same value it currently holds: ${JSON.stringify(value)}` | ||
) | ||
} | ||
await atom.set(value) | ||
@@ -64,0 +50,0 @@ } |
import enforceObservableRules from './enforce-rules' | ||
const fromEventEmitter = ({ | ||
emitter, | ||
event, | ||
get, | ||
set, | ||
defaultValue, | ||
logger, | ||
warnOnSameValueSet, | ||
}) => { | ||
const fromEventEmitter = ({ emitter, event, get, set, defaultValue, logger }) => { | ||
const observe = (listener) => { | ||
@@ -23,3 +15,2 @@ emitter.on(event, listener) | ||
logger, | ||
warnOnSameValueSet, | ||
}) | ||
@@ -26,0 +17,0 @@ } |
@@ -6,3 +6,3 @@ import { get as getValueAtPath, set as setValueAtPath } from 'lodash' | ||
const createFusionAtomFactory = | ||
({ fusion, logger, warnOnSameValueSet }) => | ||
({ fusion, logger }) => | ||
({ path, defaultValue }) => { | ||
@@ -28,3 +28,2 @@ const set = async (value) => { | ||
logger, | ||
warnOnSameValueSet, | ||
}) | ||
@@ -31,0 +30,0 @@ } |
@@ -15,3 +15,2 @@ import enforceObservableRules from '../enforce-rules' | ||
deleteOpts, | ||
warnOnSameValueSet, | ||
}, | ||
@@ -39,3 +38,2 @@ }) => { | ||
logger, | ||
warnOnSameValueSet, | ||
}) | ||
@@ -42,0 +40,0 @@ } |
@@ -5,3 +5,3 @@ import createSimpleObserver from '../simple-observer' | ||
const createStorageAtomFactory = | ||
({ storage, logger, warnOnSameValueSet }) => | ||
({ storage, logger }) => | ||
({ key, defaultValue, isSoleWriter }) => { | ||
@@ -44,3 +44,2 @@ const { notify, observe } = createSimpleObserver({ enable: isSoleWriter }) | ||
logger, | ||
warnOnSameValueSet, | ||
}) | ||
@@ -47,0 +46,0 @@ } |
@@ -16,2 +16,5 @@ export { default as createAtomMock } from './factories/memory' | ||
export { default as readOnly } from './enhancers/read-only' | ||
export { default as warnOnSameValueSet } from './enhancers/warn-on-same-value-set' | ||
export { default as swallowObserverErrors } from './enhancers/swallow-observer-errors' | ||
export { default as timeoutObservers } from './enhancers/timeout-observers' | ||
export { default as enforceObservableRules } from './enforce-rules' |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20166
24
542