@solid-primitives/utils
Advanced tools
Comparing version 3.1.0 to 4.0.0
@@ -165,57 +165,2 @@ import { Accessor, Setter, onCleanup } from 'solid-js'; | ||
}): Readonly<T>; | ||
declare type Trigger = [track: VoidFunction, dirty: VoidFunction]; | ||
/** | ||
* Set listeners in reactive computations and then trigger them when you want. | ||
* @returns `[track function, dirty function]` | ||
* @example | ||
* const [track, dirty] = createTrigger() | ||
* createEffect(() => { | ||
* track() | ||
* ... | ||
* }) | ||
* // later | ||
* dirty() | ||
*/ | ||
declare const createTrigger: () => Trigger; | ||
declare type TriggerCache<T> = { | ||
track: (v: T) => void; | ||
dirty: (v: T) => void; | ||
dirtyAll: VoidFunction; | ||
}; | ||
/** | ||
* Set listeners in reactive computations and then trigger them when you want. Cache trackers by a `key`. | ||
* @returns `{ track, dirty, dirtyAll }` functions | ||
* `track` and `dirty` are called with a `key` so that each tracker will trigger an update only when his individual `key` would get marked as dirty. | ||
* @example | ||
* const { track, dirty } = createTriggerCache() | ||
* createEffect(() => { | ||
* track(1) | ||
* ... | ||
* }) | ||
* // later | ||
* dirty(1) | ||
* // this won't cause an update: | ||
* dirty(2) | ||
*/ | ||
declare function createTriggerCache<T>(): TriggerCache<T>; | ||
declare type WeakTriggerCache<T extends object> = { | ||
track: (v: T) => void; | ||
dirty: (v: T) => void; | ||
}; | ||
/** | ||
* Set listeners in reactive computations and then trigger them when you want. Cache trackers by a `key`. | ||
* @returns `{ track, dirty }` functions | ||
* `track` and `dirty` are called with a `key` so that each tracker will trigger an update only when his individual `key` would get marked as dirty. | ||
* @example | ||
* const { track, dirty } = createWeakTriggerCache() | ||
* createEffect(() => { | ||
* track(1) | ||
* ... | ||
* }) | ||
* // later | ||
* dirty(1) | ||
* // this won't cause an update: | ||
* dirty(2) | ||
*/ | ||
declare function createWeakTriggerCache<T extends object>(): WeakTriggerCache<T>; | ||
declare type StaticStoreSetter<T extends Readonly<AnyStatic>> = { | ||
@@ -246,2 +191,2 @@ (setter: (prev: T) => Partial<T>): T; | ||
export { AccessReturnTypes, AnyClass, AnyFunction, AnyObject, AnyStatic, DeepPartialAny, Directive, ExtractIfPossible, Falsy, FalsyValue, ItemsOf, ItemsOfMany, Many, MaybeAccessor, MaybeAccessorValue, Modify, ModifyDeep, NonIterable, Noop, OnAccessEffectFunction, Position, PrimitiveValue, RequiredKeys, SetterValue, Simplify, StaticStoreSetter, Tail, Trigger, TriggerCache, Truthy, UnboxLazy, UnionToIntersection, Values, WeakTriggerCache, access, accessArray, accessWith, arrayEquals, asAccessor, asArray, chain, clamp, compare, createCallbackStack, createMicrotask, createProxy, createStaticStore, createTrigger, createTriggerCache, createWeakTriggerCache, entries, forEachEntry, handleDiffArray, isClient, isDev, isObject, isProd, isServer, keys, noop, ofClass, onRootCleanup, withAccess }; | ||
export { AccessReturnTypes, AnyClass, AnyFunction, AnyObject, AnyStatic, DeepPartialAny, Directive, ExtractIfPossible, Falsy, FalsyValue, ItemsOf, ItemsOfMany, Many, MaybeAccessor, MaybeAccessorValue, Modify, ModifyDeep, NonIterable, Noop, OnAccessEffectFunction, Position, PrimitiveValue, RequiredKeys, SetterValue, Simplify, StaticStoreSetter, Tail, Truthy, UnboxLazy, UnionToIntersection, Values, access, accessArray, accessWith, arrayEquals, asAccessor, asArray, chain, clamp, compare, createCallbackStack, createMicrotask, createProxy, createStaticStore, entries, forEachEntry, handleDiffArray, isClient, isDev, isObject, isProd, isServer, keys, noop, ofClass, onRootCleanup, withAccess }; |
@@ -1,2 +0,2 @@ | ||
import { DEV, getOwner, onCleanup, createSignal, getListener, untrack, batch } from 'solid-js'; | ||
import { DEV, getOwner, onCleanup, createSignal, untrack, batch } from 'solid-js'; | ||
import { isServer as isServer$1 } from 'solid-js/web'; | ||
@@ -72,36 +72,2 @@ | ||
} | ||
var createTrigger = isDev ? () => createSignal(void 0, { equals: false, name: "trigger" }) : () => createSignal(void 0, { equals: false }); | ||
function dirtyTriggerCache(key) { | ||
const trigger = this.get(key); | ||
if (trigger) | ||
trigger[1](); | ||
} | ||
function dirtyAllTriggerCache() { | ||
this.forEach((s) => s[1]()); | ||
} | ||
function trackTriggerCache(key) { | ||
if (!getListener()) | ||
return; | ||
let trigger = this.get(key); | ||
if (!trigger) { | ||
trigger = createTrigger(); | ||
this.set(key, trigger); | ||
} | ||
trigger[0](); | ||
} | ||
function createTriggerCache() { | ||
const cache = /* @__PURE__ */ new Map(); | ||
return { | ||
dirty: dirtyTriggerCache.bind(cache), | ||
dirtyAll: dirtyAllTriggerCache.bind(cache), | ||
track: trackTriggerCache.bind(cache) | ||
}; | ||
} | ||
function createWeakTriggerCache() { | ||
const cache = /* @__PURE__ */ new WeakMap(); | ||
return { | ||
dirty: dirtyTriggerCache.bind(cache), | ||
track: trackTriggerCache.bind(cache) | ||
}; | ||
} | ||
function createStaticStore(init) { | ||
@@ -182,2 +148,2 @@ const copy = { ...init }; | ||
export { access, accessArray, accessWith, arrayEquals, asAccessor, asArray, chain, clamp, compare, createCallbackStack, createMicrotask, createProxy, createStaticStore, createTrigger, createTriggerCache, createWeakTriggerCache, entries, forEachEntry, handleDiffArray, isClient, isDev, isObject, isProd, isServer, keys, noop, ofClass, onRootCleanup, withAccess }; | ||
export { access, accessArray, accessWith, arrayEquals, asAccessor, asArray, chain, clamp, compare, createCallbackStack, createMicrotask, createProxy, createStaticStore, entries, forEachEntry, handleDiffArray, isClient, isDev, isObject, isProd, isServer, keys, noop, ofClass, onRootCleanup, withAccess }; |
{ | ||
"name": "@solid-primitives/utils", | ||
"version": "3.1.0", | ||
"version": "4.0.0", | ||
"description": "A bunch of reactive utility types and functions, for building primitives with Solid.js", | ||
@@ -41,3 +41,3 @@ "author": "Damian Tarnawski @thetarnav <gthetarnav@gmail.com>", | ||
"prettier": "^2.7.1", | ||
"solid-js": "^1.5.0", | ||
"solid-js": "^1.6.0", | ||
"tslib": "^2.4.0", | ||
@@ -49,3 +49,3 @@ "tsup": "^6.2.3", | ||
"peerDependencies": { | ||
"solid-js": "^1.5.0" | ||
"solid-js": "^1.6.0" | ||
}, | ||
@@ -52,0 +52,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
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
20958
507