Skip to content

Instantly share code, notes, and snippets.

@coodoo

coodoo/gpx.js

Created May 27, 2020
Embed
What would you like to do?
{
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

This comment has been minimized.

Copy link
Owner Author

@coodoo coodoo commented May 27, 2020

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

@coodoo

This comment has been minimized.

Copy link
Owner Author

@coodoo 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