File tree 2 files changed +8
-7
lines changed
2 files changed +8
-7
lines changed Original file line number Diff line number Diff line change 1
1
import { run_all , noop , get_store_value , safe_not_equal } from './internal' ;
2
2
3
- export function readable ( start , value ) {
4
- const { set, subscribe } = writable ( value , ( ) => start ( set ) ) ;
5
- return { subscribe } ;
3
+ export function readable ( value , start ) {
4
+ return {
5
+ subscribe : writable ( value , start ) . subscribe
6
+ } ;
6
7
}
7
8
8
9
export function writable ( value , start = noop ) {
@@ -25,7 +26,7 @@ export function writable(value, start = noop) {
25
26
function subscribe ( run , invalidate = noop ) {
26
27
const subscriber = [ run , invalidate ] ;
27
28
subscribers . push ( subscriber ) ;
28
- if ( subscribers . length === 1 ) stop = start ( ) || noop ;
29
+ if ( subscribers . length === 1 ) stop = start ( set ) || noop ;
29
30
run ( value ) ;
30
31
31
32
return ( ) => {
@@ -45,7 +46,7 @@ export function derive(stores, fn) {
45
46
const auto = fn . length < 2 ;
46
47
let value = { } ;
47
48
48
- return readable ( set => {
49
+ return readable ( undefined , set => {
49
50
let inited = false ;
50
51
const values = [ ] ;
51
52
Original file line number Diff line number Diff line change @@ -66,7 +66,7 @@ describe('store', () => {
66
66
let running ;
67
67
let tick ;
68
68
69
- const store = readable ( set => {
69
+ const store = readable ( undefined , set => {
70
70
tick = set ;
71
71
running = true ;
72
72
@@ -192,7 +192,7 @@ describe('store', () => {
192
192
193
193
describe ( 'get' , ( ) => {
194
194
it ( 'gets the current value of a store' , ( ) => {
195
- const store = readable ( ( ) => { } , 42 ) ;
195
+ const store = readable ( 42 , ( ) => { } ) ;
196
196
assert . equal ( get ( store ) , 42 ) ;
197
197
} ) ;
198
198
} ) ;
You can’t perform that action at this time.
0 commit comments