Forráskód Böngészése

Merge branch 'master' into feature/core-events

Ryan Chandler 5 éve
szülő
commit
12f8d4d0de

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 0 - 0
dist/spruce.js


A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 0 - 0
dist/spruce.js.map


A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 0 - 0
dist/spruce.module.js


A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 0 - 0
dist/spruce.module.js.map


A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 0 - 0
dist/spruce.umd.js


A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 0 - 0
dist/spruce.umd.js.map


+ 4 - 2
src/index.js

@@ -1,4 +1,4 @@
-import { domReady, buildInitExpression } from './utils'
+import { domReady, buildInitExpression, isNullOrUndefined } from './utils'
 import { createObservable } from './observable'
 import EventBus from './bus'
 
@@ -40,10 +40,12 @@ const Spruce = {
         }
     },
 
-    store: function (name, state = {}) {
+    store: function (name, state) {
         if (! this.stores[name]) {
             this.stores[name] = state
         }
+
+        return this.stores[name]
     },
 
     subscribe(el) {

+ 4 - 4
tests/store.spec.js

@@ -9,11 +9,11 @@ test('Spruce.store() > namespace and data set correctly', () => {
         foo: 'bar'
     })
 
-    expect(Spruce.stores.testing).toEqual({
+    expect(Spruce.store('testing')).toEqual({
         foo: 'bar'
     })
 
-    expect(Spruce.stores.testing.foo).toEqual('bar')
+    expect(Spruce.store('testing').foo).toEqual('bar')
 })
 
 test('Spruce.store() > existing namespace will not be overwritten', () => {
@@ -21,7 +21,7 @@ test('Spruce.store() > existing namespace will not be overwritten', () => {
         foo: 'bar'
     })
 
-    expect(Spruce.stores.testing).toEqual({
+    expect(Spruce.store('testing')).toEqual({
         foo: 'bar'
     })
 
@@ -29,7 +29,7 @@ test('Spruce.store() > existing namespace will not be overwritten', () => {
         bob: 'car'
     })
 
-    expect(Spruce.stores.testing).toEqual({
+    expect(Spruce.store('testing')).toEqual({
         foo: 'bar'
     })
 })

Nem az összes módosított fájl került megjelenítésre, mert túl sok fájl változott