| 36 | } |
| 37 | |
| 38 | static override async onLoad(): Promise<void> { |
| 39 | const state = this.engine.state('canvas'); |
| 40 | |
| 41 | if (state.length === 0) { |
| 42 | return; |
| 43 | } |
| 44 | |
| 45 | const promises = []; |
| 46 | for (const canvas of state) { |
| 47 | const action: ActionInstance | null = this.engine.prepareAction(canvas, { cycle: 'Application' }); |
| 48 | |
| 49 | if (action === null) { |
| 50 | continue; |
| 51 | } |
| 52 | |
| 53 | const promise = action.willApply().then(() => { |
| 54 | return action.apply().then(() => { |
| 55 | return action.didApply({ updateHistory: false, updateState: false }); |
| 56 | }); |
| 57 | }); |
| 58 | |
| 59 | promises.push(promise); |
| 60 | } |
| 61 | |
| 62 | if (promises.length > 0) { |
| 63 | await Promise.all(promises); |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | static override async setup(): Promise<void> { |
| 68 | this.engine.history('canvas'); |