Skip to content

Commit b92abbf

Browse files
docs(website): add names to functions of router guide
1 parent 4282ec1 commit b92abbf

File tree

3 files changed

+24
-95
lines changed

3 files changed

+24
-95
lines changed

packages/overmind-website/examples/guide/routing/compose.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,29 @@ import { Operator, mutate, filter } from 'overmind'
88
import { Page } from './types'
99
1010
export const closeUserModal: <T>() => Operator<T> = () =>
11-
mutate(({ state }) => {
11+
mutate(function closeUserModal({ state }) {
1212
state.modalUser = null
1313
})
1414
1515
export const setPage: <T>(page: Page) => Operator<T> = (page) =>
16-
mutate(({ state }) => {
16+
mutate(function setPage({ state }) {
1717
state.currentPage = page
1818
})
1919
2020
export const shouldLoadUsers: <T>() => Operator<T> = () =>
21-
filter(({ state }) => {
21+
filter(function shouldLoadUsers({ state }) {
2222
return !Boolean(state.users.length)
2323
})
2424
2525
export const loadUsers: <T>() => Operator<T> = () =>
26-
mutate(async ({ state, effects }) => {
26+
mutate(async function loadUsers({ state, effects }) {
2727
state.isLoadingUsers = true
2828
state.users = await effects.api.getUsers()
2929
state.isLoadingUsers = false
3030
})
3131
3232
export const loadUserWithDetails: () => Operator<{ id: string }> = () =>
33-
mutate(async ({ state, effects }, params) => {
33+
mutate(async function loadUserWithDetails({ state, effects }, params) {
3434
state.isLoadingUserDetails = true
3535
state.modalUser = await effects.api.getUserWithDetails(params.id)
3636
state.isLoadingUserDetails = false
@@ -69,29 +69,29 @@ export const showUserModal: Operator<{ id: string }> = pipe(
6969
import { mutate, filter } from 'overmind'
7070
7171
export const closeUserModal = () =>
72-
mutate(({ state }) => {
72+
mutate(function closeUserModal({ state }) {
7373
state.modalUser = null
7474
})
7575
7676
export const setPage = (page) =>
77-
mutate(({ state }) => {
77+
mutate(function setPage({ state }) {
7878
state.currentPage = page
7979
})
8080
8181
export const shouldLoadUsers = () =>
82-
filter(({ state }) => {
82+
filter(function shouldLoadUsers({ state }) {
8383
return !Boolean(state.users.length)
8484
})
8585
8686
export const loadUsers = () =>
87-
mutate(async ({ state, effects }) => {
87+
mutate(async function loadUsers({ state, effects }) {
8888
state.isLoadingUsers = true
8989
state.users = await effects.api.getUsers()
9090
state.isLoadingUsers = false
9191
})
9292
9393
export const loadUserWithDetails = () =>
94-
mutate(async ({ state, effects }, params) => {
94+
mutate(async function loadUserWithDetails({ state, effects }, params) {
9595
state.isLoadingUserDetails = true
9696
state.modalUser = await effects.api.getUserWithDetails(params.id)
9797
state.isLoadingUserDetails = false

packages/overmind-website/examples/guide/routing/parallel.ts

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,6 @@
11
export default (ts) =>
22
ts
33
? [
4-
{
5-
fileName: 'overmind/operators.ts',
6-
code: `
7-
import { Operator, mutate, filter } from 'overmind'
8-
import { Page } from './types'
9-
10-
export const closeUserModal: <T>() => Operator<T> = () =>
11-
mutate(({ state }) => {
12-
state.modalUser = null
13-
})
14-
15-
export const setPage: <T>(page: Page) => Operator<T> = (page) =>
16-
mutate(({ state }) => {
17-
state.currentPage = page
18-
})
19-
20-
export const shouldLoadUsers: <T>() => Operator<T> = () =>
21-
filter(({ state }) => {
22-
return !Boolean(state.users.length)
23-
})
24-
25-
export const loadUsers: <T>() => Operator<T> = () =>
26-
mutate(async ({ state, effects }) => {
27-
state.isLoadingUsers = true
28-
state.users = await effects.api.getUsers()
29-
state.isLoadingUsers = false
30-
})
31-
32-
export const loadUserWithDetails: () => Operator<{ id: string }> = () =>
33-
mutate(async ({ state, effects }, params) => {
34-
state.isLoadingUserDetails = true
35-
state.modalUser = await effects.api.getUserWithDetails(params.id)
36-
state.isLoadingUserDetails = false
37-
})
38-
`,
39-
},
404
{
415
fileName: 'overmind/actions.ts',
426
code: `
@@ -67,41 +31,6 @@ export const showUserModal: Operator<{ id: string }> = pipe(
6731
},
6832
]
6933
: [
70-
{
71-
fileName: 'overmind/operators.js',
72-
code: `
73-
import { mutate, filter } from 'overmind'
74-
75-
export const closeUserModal = () =>
76-
mutate(({ state }) => {
77-
state.modalUser = null
78-
})
79-
80-
export const setPage = (page) =>
81-
mutate(({ state }) => {
82-
state.currentPage = page
83-
})
84-
85-
export const shouldLoadUsers = () =>
86-
filter(({ state }) => {
87-
return !Boolean(state.users.length)
88-
})
89-
90-
export const loadUsers = () =>
91-
mutate(async ({ state, effects }) => {
92-
state.isLoadingUsers = true
93-
state.users = await effects.api.getUsers()
94-
state.isLoadingUsers = false
95-
})
96-
97-
export const loadUserWithDetails = () =>
98-
mutate(async ({ state, effects }, params) => {
99-
state.isLoadingUserDetails = true
100-
state.modalUser = await effects.api.getUserWithDetails(params.id)
101-
state.isLoadingUserDetails = false
102-
})
103-
`,
104-
},
10534
{
10635
fileName: 'overmind/actions.js',
10736
code: `

packages/overmind-website/examples/guide/routing/tab.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,41 +8,41 @@ import { Operator, mutate, filter } from 'overmind'
88
import { Page } from './types'
99
1010
export const closeUserModal: <T>() => Operator<T> = () =>
11-
mutate(({ state }) => {
11+
mutate(function closeUserModal({ state }) {
1212
state.modalUser = null
1313
})
1414
1515
export const setPage: <T>(page: Page) => Operator<T> = () =>
16-
mutate(({ state }) => {
16+
mutate(function setPage({ state }) {
1717
state.currentPage = page
1818
})
1919
2020
export const shouldLoadUsers: <T>() => Operator<T> = () =>
21-
filter(({ state }) => {
21+
filter(function shouldLoadUsers({ state }) {
2222
return !Boolean(state.users.length)
2323
})
2424
2525
export const loadUsers: <T>() => Operator<T> = () =>
26-
mutate(async ({ state, effects }) => {
26+
mutate(async function loadUsers({ state, effects }) {
2727
state.isLoadingUsers = true
2828
state.users = await effects.api.getUsers()
2929
state.isLoadingUsers = false
3030
})
3131
3232
export const loadUserWithDetails: () => Operator<{ id: string }> = () =>
33-
mutate(async ({ state, effects }, params) => {
33+
mutate(async function loadUserWithDetails({ state, effects }, params) {
3434
state.isLoadingUserDetails = true
3535
state.modalUser = await effects.api.getUserWithDetails(params.id)
3636
state.isLoadingUserDetails = false
3737
})
3838
3939
export const shouldLoadUserWithDetails: <T>() => Operator<{ id: string }, T> = () =>
40-
filter(({ state }, params) => {
40+
filter(function shouldLoadUserWithDetails({ state }, params) {
4141
return !state.modalUser || state.modalUser.id !== params.id
4242
})
4343
4444
export const setCurrentUserModalTabIndex: <T>() => Operator<{ tab: string }, T> = () =>
45-
mutate(({ state }, params) => {
45+
mutate(function setCurrentUserModalTabIndex({ state }, params) {
4646
state.currentUserModalTabIndex = Number(params.tab)
4747
})
4848
`,
@@ -87,41 +87,41 @@ export const showUserModal: Operator<{ id: string, tab: string }> = pipe(
8787
import { mutate, filter } from 'overmind'
8888
8989
export const closeUserModal = () =>
90-
mutate(({ state }) => {
90+
mutate(function closeUserModal({ state }) {
9191
state.modalUser = null
9292
})
9393
9494
export const setPage = (page) =>
95-
mutate(({ state }) => {
95+
mutate(function setPage({ state }) {
9696
state.currentPage = page
9797
})
9898
9999
export const shouldLoadUsers: <T>() => Operator<T> = () =>
100-
filter(({ state }) => {
100+
filter(function shouldLoadUsers({ state }) {
101101
return !Boolean(state.users.length)
102102
})
103103
104104
export const loadUsers: <T>() => Operator<T> = () =>
105-
mutate(async ({ state, effects }) => {
105+
mutate(async function loadUsers({ state, effects }) {
106106
state.isLoadingUsers = true
107107
state.users = await effects.api.getUsers()
108108
state.isLoadingUsers = false
109109
})
110110
111111
export const loadUserWithDetails: () => Operator<{ id: string }> = () =>
112-
mutate(async ({ state, effects }, params) => {
112+
mutate(async function loadUserWithDetails({ state, effects }, params) {
113113
state.isLoadingUserDetails = true
114114
state.modalUser = await effects.api.getUserWithDetails(params.id)
115115
state.isLoadingUserDetails = false
116116
})
117117
118118
export const shouldLoadUserWithDetails: <T>() => Operator<{ id: string }, T> = () =>
119-
filter(({ state }, params) => {
119+
filter(function shouldLoadUserWithDetails({ state }, params) {
120120
return !state.modalUser || state.modalUser.id !== params.id
121121
})
122122
123123
export const setCurrentUserModalTabIndex: <T>() => Operator<{ tab: string }, T> = () =>
124-
mutate(({ state }, params) => {
124+
mutate(function setCurrentUserModalTabIndex({ state }, params) {
125125
state.currentUserModalTabIndex = Number(params.tab)
126126
})
127127
`,

0 commit comments

Comments
 (0)