Skip to content

Commit

Permalink
test: test nested getters change
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed Jan 20, 2020
1 parent 859eeb3 commit dc67e7b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ export const useMainStore = createStore({
}),
// optional getters
getters: {
doubleCount: state => state.counter * 2,
doubleCount: (state, getters) => state.counter * 2,
// use getters in other getters
doubleCountPlusOne: (state, { doubleCount }) => doubleCount.value * 2,
},
// optional actions
actions: {
Expand Down Expand Up @@ -328,7 +330,7 @@ export const useSharedStore = createStore({

#### Creating _Pinias_

_Not implemented_. Still under discussion, needs more feedback as this doesn't seem necessary.
_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.

Combine multiple _stores_ (gajos) into a new one:

Expand Down
2 changes: 2 additions & 0 deletions __tests__/getters.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,7 @@ describe('Store', () => {
it('can use other getters', () => {
const store = useStore()
expect(store.composed.value).toBe('EDUARDO: ok')
store.state.name = 'Ed'
expect(store.composed.value).toBe('ED: ok')
})
})

0 comments on commit dc67e7b

Please sign in to comment.