Last active
July 6, 2017 18:10
-
-
Save fabioluz/bcd7d39ed94856caf586f224f89fd1ff to your computer and use it in GitHub Desktop.
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> | |
<require from="./some-element"></require> | |
<require from="./intercept-binding-behavior"></require> | |
${message} | |
<Br> | |
<button click.delegate="changeFromVM()">Change from VM</button> | |
<hr> | |
<some-element value.bind="message & intercept"></some-element> | |
</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
export class App { | |
message = 'Hello World!'; | |
changeFromVM() { | |
this.message = Math.random(); | |
} | |
} |
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://jdanyow.github.io/rjs-bundle/node_modules/requirejs/require.js"></script> | |
<script src="https://jdanyow.github.io/rjs-bundle/config.js"></script> | |
<script src="https://jdanyow.github.io/rjs-bundle/bundles/aurelia.js"></script> | |
<script src="https://jdanyow.github.io/rjs-bundle/bundles/babel.js"></script> | |
<script> | |
require(['aurelia-bootstrapper']); | |
</script> | |
</body> | |
</html> |
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
export class InterceptBindingBehavior { | |
bind(binding, scope, interceptor) { | |
binding['originalUpdateTarget'] = binding['updateTarget']; | |
binding.updateTarget = val => { | |
alert('property was changed outside of the element'); | |
binding['originalUpdateTarget'](val); | |
} | |
} | |
unbind(binding, scope) { | |
binding.updateTarget = binding['originalUpdateTarget']; | |
binding['originalUpdateTarget'] = null; | |
} | |
} |
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> | |
${value} | |
<button click.delegate="change()">Change From Custom-Element</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 { bindable, bindingMode } from 'aurelia-framework'; | |
export class SomeElement { | |
@bindable({ defaultBindingMode: bindingMode.twoWay }) value; | |
valueChanged(newValue, oldValue) { | |
} | |
change() { | |
this.value = Math.random().toString(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment