sveltekit-search-params
Advanced tools
Comparing version 0.1.13 to 0.1.14
{ | ||
"name": "sveltekit-search-params", | ||
"version": "0.1.13", | ||
"version": "0.1.14", | ||
"repository": "git+https://github.com/paoloricciuti/sveltekit-search-params.git", | ||
@@ -5,0 +5,0 @@ "author": "Paolo Ricciuti", |
/* eslint-disable @typescript-eslint/no-empty-function */ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
import { writable } from 'svelte/store'; | ||
import { writable, get } from 'svelte/store'; | ||
import { goto } from '$app/navigation'; | ||
@@ -95,3 +95,3 @@ import { page } from '$app/stores'; | ||
export function queryParameters(options) { | ||
const { set: _set, subscribe, update } = writable(); | ||
const { set: _set, subscribe } = writable(); | ||
const setRef = { value: noop }; | ||
@@ -148,3 +148,7 @@ const unsubPage = page.subscribe(($page) => { | ||
subscribe: sub, | ||
update | ||
update: (updater) => { | ||
const currentValue = get({ subscribe }); | ||
const newValue = updater(currentValue); | ||
setRef.value(newValue); | ||
} | ||
}; | ||
@@ -157,3 +161,3 @@ } | ||
export function queryParam(name, { encode: encode = DEFAULT_ENCODER_DECODER.encode, decode: decode = DEFAULT_ENCODER_DECODER.decode, defaultValue } = DEFAULT_ENCODER_DECODER) { | ||
const { set: _set, subscribe, update } = writable(); | ||
const { set: _set, subscribe } = writable(); | ||
const setRef = { value: noop }; | ||
@@ -206,4 +210,8 @@ const unsubPage = page.subscribe(($page) => { | ||
subscribe: sub, | ||
update | ||
update: (updater) => { | ||
const currentValue = get({ subscribe }); | ||
const newValue = updater(currentValue); | ||
setRef.value(newValue); | ||
} | ||
}; | ||
} |
27753
294