File tree Expand file tree Collapse file tree 11 files changed +39
-42
lines changed
packages/overmind-website Expand file tree Collapse file tree 11 files changed +39
-42
lines changed Original file line number Diff line number Diff line change @@ -6,8 +6,8 @@ export default (ts) =>
66 code : `
77import { Operation } from 'overmind'
88
9- export const getItems: Operation.Attempt<Promise<Items>> = ({ effects }) =>
10- effects. http.get('/items')
9+ export const getItems: Operation.Attempt<any, Promise<Items>> = ({ http }) =>
10+ http.get('/items')
1111 ` ,
1212 } ,
1313 {
@@ -32,8 +32,8 @@ export const doThis: Action = action =>
3232 {
3333 fileName : 'app/operations.js' ,
3434 code : `
35- export const getItems = ({ effects }) =>
36- effects. http.get('/items')
35+ export const getItems = ({ http }) =>
36+ http.get('/items')
3737 ` ,
3838 } ,
3939 {
Original file line number Diff line number Diff line change @@ -6,8 +6,8 @@ export default (ts) =>
66 code : `
77import { Operation } from 'overmind'
88
9- export const isOnline: Operation.Filter = ({ effects }) =>
10- effects. connection.isOnline()
9+ export const isOnline: Operation.Filter = ({ connection }) =>
10+ connection.isOnline()
1111
1212export const isGreatherThan2: Operation.Filter<string> = ({ value }) =>
1313 value.length > 2
@@ -29,8 +29,8 @@ export const doThis: Action<string> = action =>
2929 {
3030 fileName : 'app/operations.js' ,
3131 code : `
32- export const isOnline = ({ effects }) =>
33- effects. connection.isOnline()
32+ export const isOnline = ({ connection }) =>
33+ connection.isOnline()
3434
3535export const isGreaterThan2 = ({ value }) =>
3636 value.length > 2
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ export default (ts) =>
77import { Operation } from 'overmind'
88
99export const getUser: Operation.Map<string, Promise<User>> =
10- ({ effects , value: id }) => effects. http.get(\`/users/\${id}\`)
10+ ({ http , value: id }) => http.get(\`/users/\${id}\`)
1111
1212export const trim: Operation.Map<string, string> =
1313 ({ value }) => value.trim()
@@ -29,7 +29,7 @@ export const doThis: Action<string> = action =>
2929 {
3030 fileName : 'app/operations.js' ,
3131 code : `
32- export const getUser = ({ effects , value: id }) =>
32+ export const getUser = ({ http , value: id }) =>
3333 http.get(\`/users/\${id}\`)
3434
3535export const trim = (_, value) =>
Original file line number Diff line number Diff line change @@ -4,12 +4,12 @@ export default (ts) =>
44 {
55 fileName : 'app/mutations.ts' ,
66 code : `
7- import { Mutate } from 'overmind'
7+ import { Operation } from 'overmind'
88
9- export const setLoading: Mutate = ({ state }) =>
9+ export const setLoading: Operation. Mutate = ({ state }) =>
1010 state.isLoading = true
1111
12- export const setInputValue: Mutate<string> = ({ state, value }) =>
12+ export const setInputValue: Operation. Mutate<string> = ({ state, value }) =>
1313 state.inputValue = value
1414 ` ,
1515 } ,
Original file line number Diff line number Diff line change @@ -6,8 +6,8 @@ export default (ts) =>
66 code : `
77import { Operation } from 'overmind'
88
9- export const trackSubmitForm: Operation.Run = ({ state, effects }) =>
10- effects. track.interaction('login', Boolean(state.user))
9+ export const trackSubmitForm: Operation.Run = ({ state, track }) =>
10+ track.interaction('login', Boolean(state.user))
1111 ` ,
1212 } ,
1313 {
@@ -35,8 +35,8 @@ export const login: Action = (action) =>
3535 {
3636 fileName : 'app/operations.js' ,
3737 code : `
38- export const trackSubmitForm = ({ effects }) =>
39- effects. track.interaction('submitForm')
38+ export const trackSubmitForm = ({ track }) =>
39+ track.interaction('submitForm')
4040 ` ,
4141 } ,
4242 {
Original file line number Diff line number Diff line change @@ -6,8 +6,8 @@ export default (ts) =>
66 code : `
77import { Operation } from 'overmind'
88
9- export const hasToken: Operation.When = ({ effects }) =>
10- Boolean(effects. localStorage.get('token'))
9+ export const hasToken: Operation.When = ({ localStorage }) =>
10+ Boolean(localStorage.get('token'))
1111 ` ,
1212 } ,
1313 {
@@ -32,8 +32,8 @@ export const doThis: Action = action =>
3232 {
3333 fileName : 'app/operations.js' ,
3434 code : `
35- export const hasToken = ({ effects }) =>
36- Boolean(effects. localStorage.get('token'))
35+ export const hasToken = ({ localStorage }) =>
36+ Boolean(localStorage.get('token'))
3737 ` ,
3838 } ,
3939 {
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ export default (ts, view) =>
44 {
55 fileName : 'app.ts' ,
66 code : `
7- import App , { modules } from 'overmind'
7+ import Overmind , { TApp, modules } from 'overmind'
88import createConnect, { TConnect } from 'overmind-${ view } '
99import * as moduleA from './moduleA'
1010import * as moduleB from './moduleB'
@@ -20,11 +20,9 @@ const config = modules({
2020})
2121
2222declare module 'overmind' {
23- interface IState extends TState<typeof config> {}
24- interface IEffects extends TEffects<typeof config> {}
23+ interface App extends TApp<typeof config> {}
2524}
2625
27-
2826const app = new App(config)
2927
3028export type Connect = TConnect<typeof app>
Original file line number Diff line number Diff line change @@ -4,15 +4,15 @@ export default (ts) =>
44 {
55 fileName : 'app/mutations.js' ,
66 code : `
7- import { Mutate } from 'overmind'
7+ import { Operation } from 'overmind'
88
9- export const setValue: Mutate = ({ state }) =>
9+ export const setValue: Operation. Mutate = ({ state }) =>
1010 state.value = 'foo'
1111
12- export const setValueFromAction: Mutate<string> = ({ state, value }) =>
12+ export const setValueFromAction: Operation. Mutate<string> = ({ state, value }) =>
1313 state.value2 = value
1414
15- export const setValueFromState: Mutate = ({ state }) =>
15+ export const setValueFromState: Operation. Mutate = ({ state }) =>
1616 state.value3 = state.value
1717 ` ,
1818 } ,
Original file line number Diff line number Diff line change @@ -18,16 +18,16 @@ export let posts: Post[] = []
1818 {
1919 fileName : 'app/mutations.ts' ,
2020 code : `
21- import { Mutate } from 'overmind'
21+ import { Operation } from 'overmind'
2222import { Post } from './state'
2323
24- export const setLoadingPosts: Mutate = ({ state }) =>
24+ export const setLoadingPosts: Operation. Mutate = ({ state }) =>
2525 state.isLoadingPosts = true
2626
27- export const unsetLoadingPosts: Mutate = ({ state }) =>
27+ export const unsetLoadingPosts: Operation. Mutate = ({ state }) =>
2828 state.isLoadingPosts = false
2929
30- export const setPosts: Mutate<Post[]> = ({ state, value: posts }) =>
30+ export const setPosts: Operation. Mutate<Post[]> = ({ state, value: posts }) =>
3131 state.posts = posts
3232 ` ,
3333 } ,
Original file line number Diff line number Diff line change @@ -2,16 +2,15 @@ const getVersion = () => (location.host.split('.')[0] === 'next' ? '@next' : '')
22
33export const tsAppIndex = ( view , config ) => {
44 return `
5- import App from 'overmind'
5+ import Overmind, { TApp } from 'overmind'
66import createConnect, { TConnect } from 'overmind-${ view } '
77${ config . trim ( ) }
88
99declare module 'overmind' {
10- interface IState extends TState<typeof config> {}
11- interface IEffects extends TEffects<typeof config> {}
10+ interface App extends TApp<typeof config> {}
1211}
1312
14- const app = new App (config)
13+ const app = new Overmind (config)
1514
1615export type Connect = TConnect<typeof app>
1716
You can’t perform that action at this time.
0 commit comments