Single-file Components
// ./wires/Counter.bx
class extends="cbwire.models.Component" {
data = {
"counter": 0
};
function onMount() {
// Load the counter from the session
data.counter = session.counter ?: 0;
}
function save( counter ) {
// Save the counter to the session
session.counter = arguments.counter;
}
}// ./wires/Counter.cfc
component extends="cbwire.models.Component" {
data = {
"counter": 0
};
function onMount() {
// Load the counter from the session
data.counter = session.counter ?: 0;
}
function save( counter ) {
// Save the counter to the session
session.counter = arguments.counter;
}
}<!--- ./wires/counter.bxm|cfm --->
<div
x-data="{
counter: $wire.counter,
increment() {
this.counter++
},
async save() {
// Call the save method on our component
await $wire.save( this.counter );
}
}"
wire:ignore.self>
<div>Count: <span x-text="counter"></span></div>
<button @click="increment">+</button>
<button @click="save">Save</button>
</div>Single File Format
Performance
Was this helpful?