Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- export abstract class BlockingAction {
- type: string;
- abstract setup(iter: IterableIterator<BlockingAction>): void;
- handleNext(iter: IterableIterator<BlockingAction>): void {
- let n = iter.next();
- if(n.done)
- return;
- n.value.setup(iter);
- };
- public static startCoroutine(func: () => IterableIterator<BlockingAction>): void {
- let iter = func();
- let n = iter.next();
- if(n.done)
- return;
- n.value.setup(iter);
- }
- }
- export class Wait extends BlockingAction {
- wait: number;
- constructor(timeout : number) {
- super();
- this.wait = timeout;
- }
- setup(iter: IterableIterator<BlockingAction>) : void {
- let t = this;
- setTimeout(function(){
- t.handleNext(iter);
- }, this.wait);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement