Last active
May 4, 2016 16:47
-
-
Save qtuan/78044ecbbd4b7c9480254f2d3ae9cfa9 to your computer and use it in GitHub Desktop.
Aurelia global var subscription
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
See console | |
<button click.delegate="change()">Change</button> | |
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {inject} from 'aurelia-dependency-injection'; | |
import {BindingEngine} from 'aurelia-binding'; | |
@inject(BindingEngine) | |
export class App { | |
constructor(bindingEngine) { | |
this.bindingEngine = bindingEngine; | |
let subscription = bindingEngine.propertyObserver(window, 'count') | |
.subscribe((newValue, oldValue) => console.log('Global count: ', newValue, oldValue)); | |
let subscription2 = bindingEngine.propertyObserver(window, 'count2') | |
.subscribe((newValue, oldValue) => console.log('window.count2: ', newValue, oldValue)); | |
let subscription3 = bindingEngine.propertyObserver(window, 'count3') | |
.subscribe((newValue, oldValue) => console.log('Global count3: ', newValue, oldValue)); | |
} | |
change() { | |
count++; | |
count2++; | |
count3++; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<title>Aurelia</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
</head> | |
<body aurelia-app> | |
<h1>Loading...</h1> | |
<script src="https://cdn.rawgit.com/jdanyow/aurelia-bundle/v1.0.3/jspm_packages/system.js"></script> | |
<script src="https://cdn.rawgit.com/jdanyow/aurelia-bundle/v1.0.3/config.js"></script> | |
<script> | |
count = 0; | |
window.count2 = 0; | |
var count3 = 0; | |
</script> | |
<script> | |
System.import('aurelia-bootstrapper'); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment