[IMP] add browser bindings to standard environment

This could be done by each application, but it does cost only a few
lines of code, and it helps standardizing the Owl ecosystem.

For example, some library (such as o_spreadsheet) needs to mock side
effects, and Odoo also needs to do that, so this prevents duplicated effort.

closes #686
This commit is contained in:
Géry Debongnie
2020-04-17 12:12:02 +02:00
committed by aab-odoo
parent 142b69823f
commit 1707bd240d
7 changed files with 70 additions and 9 deletions
+4 -4
View File
@@ -1,4 +1,5 @@
import { Fiber } from "./fiber";
import { browser } from "../browser";
/**
* Owl Scheduler Class
@@ -19,9 +20,9 @@ interface Task {
export class Scheduler {
tasks: Task[] = [];
isRunning: boolean = false;
requestAnimationFrame: typeof window.requestAnimationFrame;
requestAnimationFrame: Window["requestAnimationFrame"];
constructor(requestAnimationFrame) {
constructor(requestAnimationFrame: Window["requestAnimationFrame"]) {
this.requestAnimationFrame = requestAnimationFrame;
}
@@ -109,5 +110,4 @@ export class Scheduler {
}
}
const raf = window.requestAnimationFrame.bind(window);
export const scheduler = new Scheduler(raf);
export const scheduler = new Scheduler(browser.requestAnimationFrame);