-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(state): make states readonly in components
- Loading branch information
1 parent
0d886a4
commit 5d00974
Showing
3 changed files
with
21 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,18 @@ | ||
import { reactive, toRefs } from 'vue'; | ||
import { reactive, readonly, toRefs } from 'vue'; | ||
import SpacesService from '@/api/SpacesService'; | ||
|
||
const state = reactive({ | ||
spaces: [] | ||
}); | ||
|
||
export function useSpacesState() { | ||
const fetchSpaces = () => SpacesService.fetchUserSpaces().then( | ||
spaces => state.spaces = spaces | ||
); | ||
const fetchSpaces = () => SpacesService.fetchUserSpaces().then( | ||
spaces => state.spaces = spaces | ||
); | ||
|
||
export function useSpacesState() { | ||
const readonlyState = readonly(state); | ||
return { | ||
...toRefs(state), | ||
...toRefs(readonlyState), | ||
fetchSpaces | ||
}; | ||
} |