admin管理员组文章数量:1427307
How would one abstract away the usage of browser's window
object when using the Aurelia framework? I would like to avoid direct dependency on the browser when using functionality such as setInterval
or addEventListener
for example.
Aurelia has something called Platform Abstraction Library which in theory should provide the functionality I am looking for. However, I could not find any documentation about it at the time of writing this question.
How would one abstract away the usage of browser's window
object when using the Aurelia framework? I would like to avoid direct dependency on the browser when using functionality such as setInterval
or addEventListener
for example.
Aurelia has something called Platform Abstraction Library which in theory should provide the functionality I am looking for. However, I could not find any documentation about it at the time of writing this question.
Share Improve this question asked Jan 17, 2016 at 18:04 Jaanus VarusJaanus Varus 3,5833 gold badges33 silver badges52 bronze badges1 Answer
Reset to default 11Few examples:
import {DOM, PLATFORM, FEATURE} from 'aurelia-pal';
PLATFORM.addEventListener('click', e => ...);
PLATFORM.requestAnimationFrame(() => ...);
let event = DOM.createCustomEvent('foo', { bubbles: true });
DOM.dispatchEvent(event);
let element = DOM.createElement('div');
if (FEATURE.shadowDOM && FEATURE.scopedCSS && FEATURE.htmlTemplateElement) {
...
}
There's no setTimeout
/ setInterval
in the PAL- I think because aurelia doesn't use I've added an issue to get these added.setTimeout
.
本文标签: javascriptHow to abstract away the usage of browser39s window objectStack Overflow
版权声明:本文标题:javascript - How to abstract away the usage of browser's window object? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745496217a2660819.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论