Skip to content

Instantly share code, notes, and snippets.

@coodoo
Created May 27, 2020 04:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coodoo/eedf84a9be3fd6dc6195adff0a772367 to your computer and use it in GitHub Desktop.
Save coodoo/eedf84a9be3fd6dc6195adff0a772367 to your computer and use it in GitHub Desktop.
{
id: 'Root',
initial: 'after map loaded',
states: {
'before map loaded': {
on: {},
states: {}
},
'after map loaded': {
on: {},
states: {
'route color': {
on: {},
states: {}
},
'map style': {
on: {},
states: {}
},
'gpx upload': {
on: {},
states: {
pending: {
on: {},
states: {}
},
failure: {
on: {},
states: {}
},
success: {
on: {},
states: {},
type: 'parallel'
}
}
}
},
type: 'parallel',
initial: 'route color'
}
},
on: {}
}
@coodoo
Copy link
Author

coodoo commented May 27, 2020

Screen Shot 2020-05-27 at 12 55 59 PM

@coodoo
Copy link
Author

coodoo commented May 28, 2020

colorstyle 放在 subMachine{} 內,這樣寫一次即可供 before loadafter load 使用。

//
const subMachine = {
	type: 'parallel',
	states: {
		'route color': {
			on: {},
			states: {}
		},
		'map style': {
			on: {},
			states: {}
		}
	}
}

//
const main = {
	id: 'Root',
	initial: 'before map loaded',
	states: {
		'before map loaded': {
			on: {},
			states: {}
		},
		'after map loaded': {
			initial: 'route color',
			on: {},
			states: {
				loading: {
					on: {},
					states: {
						pending: {
							on: {},
							states: {}
						},
						failure: {
							on: {},
							states: {}
						},
						success: {
							on: {},
							states: {},
						}
					}
				},
				'before load': {
					on: {},
					states: subMachine
				},
				'after load': {
					on: {},
					states: subMachine
				}
			}
		}
	},
	on: {}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment