Skip to content

Commit dc67e7b

Browse files
committed
test: test nested getters change
1 parent 859eeb3 commit dc67e7b

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ export const useMainStore = createStore({
9494
}),
9595
// optional getters
9696
getters: {
97-
doubleCount: state => state.counter * 2,
97+
doubleCount: (state, getters) => state.counter * 2,
98+
// use getters in other getters
99+
doubleCountPlusOne: (state, { doubleCount }) => doubleCount.value * 2,
98100
},
99101
// optional actions
100102
actions: {
@@ -328,7 +330,7 @@ export const useSharedStore = createStore({
328330

329331
#### Creating _Pinias_
330332

331-
_Not implemented_. Still under discussion, needs more feedback as this doesn't seem necessary.
333+
_Not implemented_. Still under discussion, needs more feedback as this doesn't seem necessary because it can be replaced by shared stores as shown above.
332334

333335
Combine multiple _stores_ (gajos) into a new one:
334336

__tests__/getters.spec.ts

+2
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,7 @@ describe('Store', () => {
6464
it('can use other getters', () => {
6565
const store = useStore()
6666
expect(store.composed.value).toBe('EDUARDO: ok')
67+
store.state.name = 'Ed'
68+
expect(store.composed.value).toBe('ED: ok')
6769
})
6870
})

0 commit comments

Comments
 (0)