|
|
@ -1,8 +1,9 @@
|
|
|
|
import { run_all, noop, get_store_value, safe_not_equal } from './internal';
|
|
|
|
import { run_all, noop, get_store_value, safe_not_equal } from './internal';
|
|
|
|
|
|
|
|
|
|
|
|
export function readable(start, value) {
|
|
|
|
export function readable(value, start) {
|
|
|
|
const { set, subscribe } = writable(value, () => start(set));
|
|
|
|
return {
|
|
|
|
return { subscribe };
|
|
|
|
subscribe: writable(value, start).subscribe
|
|
|
|
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export function writable(value, start = noop) {
|
|
|
|
export function writable(value, start = noop) {
|
|
|
@ -25,7 +26,7 @@ export function writable(value, start = noop) {
|
|
|
|
function subscribe(run, invalidate = noop) {
|
|
|
|
function subscribe(run, invalidate = noop) {
|
|
|
|
const subscriber = [run, invalidate];
|
|
|
|
const subscriber = [run, invalidate];
|
|
|
|
subscribers.push(subscriber);
|
|
|
|
subscribers.push(subscriber);
|
|
|
|
if (subscribers.length === 1) stop = start() || noop;
|
|
|
|
if (subscribers.length === 1) stop = start(set) || noop;
|
|
|
|
run(value);
|
|
|
|
run(value);
|
|
|
|
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
return () => {
|
|
|
@ -45,7 +46,7 @@ export function derive(stores, fn) {
|
|
|
|
const auto = fn.length < 2;
|
|
|
|
const auto = fn.length < 2;
|
|
|
|
let value = {};
|
|
|
|
let value = {};
|
|
|
|
|
|
|
|
|
|
|
|
return readable(set => {
|
|
|
|
return readable(undefined, set => {
|
|
|
|
let inited = false;
|
|
|
|
let inited = false;
|
|
|
|
const values = [];
|
|
|
|
const values = [];
|
|
|
|
|
|
|
|
|
|
|
|