Created
March 9, 2021 14:21
-
-
Save Seebiscuit/c7c8113646e4a928f1b876830e6a082a to your computer and use it in GitHub Desktop.
Bindable binding behavior between consumer and component
This file contains hidden or 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> | |
<meta charset="utf-8"> | |
<title>Dumber Gist</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no"> | |
<base href="/"> | |
</head> | |
<!-- | |
Dumber gist uses dumber bundler, the default bundle file | |
is /dist/entry-bundle.js. | |
The starting module is pointed to aurelia-bootstrapper | |
(data-main attribute on script) for Aurelia, | |
The aurelia bootstrapper then loads up user module "main" | |
(aurelia-app attribute on <body>) which is your src/main.js. | |
--> | |
<body aurelia-app="main"> | |
<script src="/dist/entry-bundle.js" data-main="aurelia-bootstrapper"></script> | |
</body> | |
</html> |
This file contains hidden or 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
{ | |
"dependencies": { | |
"aurelia-bootstrapper": "^2.3.3" | |
} | |
} |
This file contains hidden or 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="dumb-toggle"></require> | |
<dumb-toggle | |
is-boolean.bind="otherBoolean" | |
on-toggle-status.call="toggleStatus()"> | |
</dumb-toggle> | |
</template> |
This file contains hidden or 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 { TaskQueue, inject } from 'aurelia-framework'; | |
@inject(TaskQueue) | |
export class App { | |
otherBoolean = false; | |
asyncBoolean = false; | |
constructor(taskQueue) { | |
this.taskQueue = taskQueue; | |
} | |
counter = 0; | |
toggleStatus() { | |
console.log("--- App Toggle", this.otherBoolean); | |
if (!(this.counter % 2) || !this.counter) { | |
this.otherBoolean = !this.otherBoolean; | |
} | |
this.counter++; | |
console.log("App Toggle", this.otherBoolean); | |
} | |
} |
This file contains hidden or 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> | |
<div css="background-color: ${isBoolean ? 'white' : 'black'};color: ${isBoolean ? 'black' : 'white'};"> | |
A Block | |
</div> | |
<label> | |
<button click.delegate="toggleBoolean()">Update Is Boolean</button> | |
</label> | |
</template> |
This file contains hidden or 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} from "aurelia-framework" | |
export class DumbToggle { | |
@bindable onToggleStatus; | |
@bindable isBoolean = false; | |
counter = 0; | |
toggleBoolean() { | |
console.log(this.counter++, "Dumb Toggle", this.isBoolean); | |
this.isBoolean = !this.isBoolean; | |
console.log("Dumb Toggle", this.isBoolean); | |
this.onToggleStatus(); | |
console.log("Dumb Toggle Last", this.isBoolean); | |
} | |
propertyChanged(newValue) { | |
console.log("***isBoolean Changed", this.isBoolean); | |
} | |
} |
This file contains hidden or 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 function configure(aurelia) { | |
aurelia.use | |
.standardConfiguration() | |
.developmentLogging('info'); | |
aurelia.start().then(() => aurelia.setRoot()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment