Skip to content

Commit

Permalink
refactor(reactive): break change to redefine action semantics (#1930)
Browse files Browse the repository at this point in the history
  • Loading branch information
janryWang authored Aug 3, 2021
1 parent c74e7f9 commit 1b0a753
Show file tree
Hide file tree
Showing 48 changed files with 1,289 additions and 313 deletions.
3 changes: 3 additions & 0 deletions .vscode/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
"autorun",
"Formily",
"formily",
"untrack",
"untracker",
"untracked",
"Untracking",
"Unmount",
"antd",
"Antd",
Expand Down
12 changes: 6 additions & 6 deletions docs/guide/scenes/edit-detail.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const SchemaField = createSchemaField({
fetch('//unpkg.com/china-location/dist/location.json')
.then((res) => res.json())
.then(
action((data) => {
action.bound((data) => {
field.dataSource = transform(data)
field.loading = false
})
Expand Down Expand Up @@ -408,7 +408,7 @@ const SchemaField = createSchemaField({
fetch('//unpkg.com/china-location/dist/location.json')
.then((res) => res.json())
.then(
action((data) => {
action.bound((data) => {
field.dataSource = transform(data)
field.loading = false
})
Expand Down Expand Up @@ -731,7 +731,7 @@ const fetchAddress = (field) => {
fetch('//unpkg.com/china-location/dist/location.json')
.then((res) => res.json())
.then(
action((data) => {
action.bound((data) => {
field.dataSource = transform(data)
field.loading = false
})
Expand Down Expand Up @@ -1058,7 +1058,7 @@ const SchemaField = createSchemaField({
fetch('//unpkg.com/china-location/dist/location.json')
.then((res) => res.json())
.then(
action((data) => {
action.bound((data) => {
field.dataSource = transform(data)
field.loading = false
})
Expand Down Expand Up @@ -1379,7 +1379,7 @@ const SchemaField = createSchemaField({
fetch('//unpkg.com/china-location/dist/location.json')
.then((res) => res.json())
.then(
action((data) => {
action.bound((data) => {
field.dataSource = transform(data)
field.loading = false
})
Expand Down Expand Up @@ -1702,7 +1702,7 @@ const fetchAddress = (field) => {
fetch('//unpkg.com/china-location/dist/location.json')
.then((res) => res.json())
.then(
action((data) => {
action.bound((data) => {
field.dataSource = transform(data)
field.loading = false
})
Expand Down
12 changes: 6 additions & 6 deletions docs/guide/scenes/edit-detail.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const SchemaField = createSchemaField({
fetch('//unpkg.com/china-location/dist/location.json')
.then((res) => res.json())
.then(
action((data) => {
action.bound((data) => {
field.dataSource = transform(data)
field.loading = false
})
Expand Down Expand Up @@ -404,7 +404,7 @@ const SchemaField = createSchemaField({
fetch('//unpkg.com/china-location/dist/location.json')
.then((res) => res.json())
.then(
action((data) => {
action.bound((data) => {
field.dataSource = transform(data)
field.loading = false
})
Expand Down Expand Up @@ -723,7 +723,7 @@ const fetchAddress = (field) => {
fetch('//unpkg.com/china-location/dist/location.json')
.then((res) => res.json())
.then(
action((data) => {
action.bound((data) => {
field.dataSource = transform(data)
field.loading = false
})
Expand Down Expand Up @@ -1048,7 +1048,7 @@ const SchemaField = createSchemaField({
fetch('//unpkg.com/china-location/dist/location.json')
.then((res) => res.json())
.then(
action((data) => {
action.bound((data) => {
field.dataSource = transform(data)
field.loading = false
})
Expand Down Expand Up @@ -1363,7 +1363,7 @@ const SchemaField = createSchemaField({
fetch('//unpkg.com/china-location/dist/location.json')
.then((res) => res.json())
.then(
action((data) => {
action.bound((data) => {
field.dataSource = transform(data)
field.loading = false
})
Expand Down Expand Up @@ -1680,7 +1680,7 @@ const fetchAddress = (field) => {
fetch('//unpkg.com/china-location/dist/location.json')
.then((res) => res.json())
.then(
action((data) => {
action.bound((data) => {
field.dataSource = transform(data)
field.loading = false
})
Expand Down
6 changes: 3 additions & 3 deletions docs/guide/scenes/login-register.md
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ const SchemaField = createSchemaField({
fetch('//unpkg.com/china-location/dist/location.json')
.then((res) => res.json())
.then(
action((data) => {
action.bound((data) => {
field.dataSource = transform(data)
field.loading = false
})
Expand Down Expand Up @@ -849,7 +849,7 @@ const SchemaField = createSchemaField({
fetch('//unpkg.com/china-location/dist/location.json')
.then((res) => res.json())
.then(
action((data) => {
action.bound((data) => {
field.dataSource = transform(data)
field.loading = false
})
Expand Down Expand Up @@ -1321,7 +1321,7 @@ export default () => {
fetch('//unpkg.com/china-location/dist/location.json')
.then((res) => res.json())
.then(
action((data) => {
action.bound((data) => {
field.dataSource = transform(data)
field.loading = false
})
Expand Down
6 changes: 3 additions & 3 deletions docs/guide/scenes/login-register.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ const SchemaField = createSchemaField({
fetch('//unpkg.com/china-location/dist/location.json')
.then((res) => res.json())
.then(
action((data) => {
action.bound((data) => {
field.dataSource = transform(data)
field.loading = false
})
Expand Down Expand Up @@ -849,7 +849,7 @@ const SchemaField = createSchemaField({
fetch('//unpkg.com/china-location/dist/location.json')
.then((res) => res.json())
.then(
action((data) => {
action.bound((data) => {
field.dataSource = transform(data)
field.loading = false
})
Expand Down Expand Up @@ -1321,7 +1321,7 @@ export default () => {
fetch('//unpkg.com/china-location/dist/location.json')
.then((res) => res.json())
.then(
action((data) => {
action.bound((data) => {
field.dataSource = transform(data)
field.loading = false
})
Expand Down
6 changes: 3 additions & 3 deletions packages/antd/docs/components/Cascader.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const useAddress = (pattern: FormPathPattern) => {
fetch('//unpkg.com/china-location/dist/location.json')
.then((res) => res.json())
.then(
action((data) => {
action.bound((data) => {
field.dataSource = transform(data)
field.loading = false
})
Expand Down Expand Up @@ -126,7 +126,7 @@ const useAsyncDataSource =
fetch(url)
.then((res) => res.json())
.then(
action((data) => {
action.bound((data) => {
field.dataSource = transform(data)
field.loading = false
})
Expand Down Expand Up @@ -204,7 +204,7 @@ const useAddress = (pattern: FormPathPattern) => {
fetch('//unpkg.com/china-location/dist/location.json')
.then((res) => res.json())
.then(
action((data) => {
action.bound((data) => {
field.dataSource = transform(data)
field.loading = false
})
Expand Down
6 changes: 3 additions & 3 deletions packages/antd/docs/components/Cascader.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const useAddress = (pattern: FormPathPattern) => {
fetch('//unpkg.com/china-location/dist/location.json')
.then((res) => res.json())
.then(
action((data) => {
action.bound((data) => {
field.dataSource = transform(data)
field.loading = false
})
Expand Down Expand Up @@ -126,7 +126,7 @@ const useAsyncDataSource =
fetch(url)
.then((res) => res.json())
.then(
action((data) => {
action.bound((data) => {
field.dataSource = transform(data)
field.loading = false
})
Expand Down Expand Up @@ -204,7 +204,7 @@ const useAddress = (pattern: FormPathPattern) => {
fetch('//unpkg.com/china-location/dist/location.json')
.then((res) => res.json())
.then(
action((data) => {
action.bound((data) => {
field.dataSource = transform(data)
field.loading = false
})
Expand Down
8 changes: 4 additions & 4 deletions packages/antd/docs/components/Select.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ const useAsyncDataSource = (
onFieldReact(pattern, (field) => {
field.loading = true
service({ field, keyword: keyword.value }).then(
action((data) => {
action.bound((data) => {
field.dataSource = data
field.loading = false
})
Expand Down Expand Up @@ -185,7 +185,7 @@ const useAsyncDataSource = (
onFieldReact(pattern, (field) => {
field.loading = true
service(field).then(
action((data) => {
action.bound((data) => {
field.dataSource = data
field.loading = false
})
Expand Down Expand Up @@ -365,7 +365,7 @@ const loadData = async (field) => {
const useAsyncDataSource = (service) => (field) => {
field.loading = true
service(field).then(
action((data) => {
action.bound((data) => {
field.dataSource = data
field.loading = false
})
Expand Down Expand Up @@ -474,7 +474,7 @@ const useAsyncDataSource = (
onFieldReact(pattern, (field) => {
field.loading = true
service(field).then(
action((data) => {
action.bound((data) => {
field.dataSource = data
field.loading = false
})
Expand Down
8 changes: 4 additions & 4 deletions packages/antd/docs/components/Select.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ const useAsyncDataSource = (
onFieldReact(pattern, (field) => {
field.loading = true
service({ field, keyword: keyword.value }).then(
action((data) => {
action.bound((data) => {
field.dataSource = data
field.loading = false
})
Expand Down Expand Up @@ -185,7 +185,7 @@ const useAsyncDataSource = (
onFieldReact(pattern, (field) => {
field.loading = true
service(field).then(
action((data) => {
action.bound((data) => {
field.dataSource = data
field.loading = false
})
Expand Down Expand Up @@ -365,7 +365,7 @@ const loadData = async (field) => {
const useAsyncDataSource = (service) => (field) => {
field.loading = true
service(field).then(
action((data) => {
action.bound((data) => {
field.dataSource = data
field.loading = false
})
Expand Down Expand Up @@ -474,7 +474,7 @@ const useAsyncDataSource = (
onFieldReact(pattern, (field) => {
field.loading = true
service(field).then(
action((data) => {
action.bound((data) => {
field.dataSource = data
field.loading = false
})
Expand Down
6 changes: 3 additions & 3 deletions packages/antd/docs/components/TreeSelect.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ const useAsyncDataSource = (
onFieldReact(pattern, (field) => {
field.loading = true
service(field).then(
action((data) => {
action.bound((data) => {
field.dataSource = data
field.loading = false
})
Expand Down Expand Up @@ -478,7 +478,7 @@ const loadData = async (field) => {
const useAsyncDataSource = (service) => (field) => {
field.loading = true
service(field).then(
action((data) => {
action.bound((data) => {
field.dataSource = data
field.loading = false
})
Expand Down Expand Up @@ -626,7 +626,7 @@ const useAsyncDataSource = (
onFieldReact(pattern, (field) => {
field.loading = true
service(field).then(
action((data) => {
action.bound((data) => {
field.dataSource = data
field.loading = false
})
Expand Down
6 changes: 3 additions & 3 deletions packages/antd/docs/components/TreeSelect.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ const useAsyncDataSource = (
onFieldReact(pattern, (field) => {
field.loading = true
service(field).then(
action((data) => {
action.bound((data) => {
field.dataSource = data
field.loading = false
})
Expand Down Expand Up @@ -478,7 +478,7 @@ const loadData = async (field) => {
const useAsyncDataSource = (service) => (field) => {
field.loading = true
service(field).then(
action((data) => {
action.bound((data) => {
field.dataSource = data
field.loading = false
})
Expand Down Expand Up @@ -626,7 +626,7 @@ const useAsyncDataSource = (
onFieldReact(pattern, (field) => {
field.loading = true
service(field).then(
action((data) => {
action.bound((data) => {
field.dataSource = data
field.loading = false
})
Expand Down
6 changes: 3 additions & 3 deletions packages/antd/src/form-step/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const createFormStep = (defaultCurrent = 0): IFormStep => {
steps: [],
}

const setDisplay = action((target: number) => {
const setDisplay = action.bound((target: number) => {
const currentStep = env.steps[target]
env.steps.forEach(({ name }) => {
env.form.query(`${env.field.address}.${name}`).take((field) => {
Expand All @@ -80,14 +80,14 @@ const createFormStep = (defaultCurrent = 0): IFormStep => {
})
})

const next = action(() => {
const next = action.bound(() => {
if (formStep.allowNext) {
setDisplay(formStep.current + 1)
formStep.setCurrent(formStep.current + 1)
}
})

const back = action(() => {
const back = action.bound(() => {
if (formStep.allowBack) {
setDisplay(formStep.current - 1)
formStep.setCurrent(formStep.current - 1)
Expand Down
Loading

0 comments on commit 1b0a753

Please sign in to comment.