githubEdit

Data Properties

Define reactive properties for your UI Wires with just a few lines of code.

Similar to Vue.js and other frontend JavaScript frameworks, you can define reactive properties on your Wires.

Defining Properties

You can define and initialize properties on your Wires using data.

component extends="cbwire.models.Component"{
    data = {
        "task": ""
    };
}
circle-exclamation
circle-check

Accessing Properties

Data Variable

You can reference a property using data.[propertyName].

component extends="cbwire.models.Component"{

    property name="taskService" inject="TaskService@myapp";
    
    // Data properties
    data = {
        "task": ""
    };
    
    // Action
    function addTask(){
        taskService.create( data.task );
    }
}

Getters

Getter methods are automatically available for your properties based on the property's name. You to access the property within your Wire using this.get[propertyName]().

circle-check

Templates

You can reference data properties within your Wire's template using args.[propertyName].

Resetting Properties

You can reset properties back to their original value using reset().

There are several ways to use reset.

Security

Your component's private variables scope will hold your data property definitions and current values, but it's necessary to be cautious about what you store.

circle-check
triangle-exclamation

Last updated

Was this helpful?