Răsfoiți Sursa

feature(return store from Spruce.store)

Ryan Chandler 5 ani în urmă
părinte
comite
be68a002e3

Fișier diff suprimat deoarece este prea mare
+ 0 - 0
dist/spruce.js


Fișier diff suprimat deoarece este prea mare
+ 0 - 0
dist/spruce.js.map


Fișier diff suprimat deoarece este prea mare
+ 0 - 0
dist/spruce.module.js


Fișier diff suprimat deoarece este prea mare
+ 0 - 0
dist/spruce.module.js.map


Fișier diff suprimat deoarece este prea mare
+ 0 - 0
dist/spruce.umd.js


Fișier diff suprimat deoarece este prea mare
+ 0 - 0
dist/spruce.umd.js.map


+ 6 - 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'
 
@@ -38,7 +38,11 @@ const Spruce = {
         }
     },
 
-    store: function (name, state = {}) {
+    store: function (name, state) {
+        if (state === undefined && this.stores[name]) {
+            return this.stores[name]
+        }
+
         if (! this.stores[name]) {
             this.stores[name] = state
         }

+ 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'
     })
 })

Unele fișiere nu au fost afișate deoarece prea multe fișiere au fost modificate în acest diff