Defer Loading

Call an action immediately once your Wire is first rendered.

You can use the wire:init Directive to execute an action as soon as your component is initially rendered.

<div wire:init="loadTasks">
    <ul>
        <cfloop array="#args.tasks#" index="task">
            <li>#task#</li>
        </cfloop>
    </ul>
</div>
component extends="cbwire.models.Component" {

    property name="taskService" inject="TaskService@myapp";
    
    data = {
        "tasks": []
    };
    
    function loadTasks(){
        data.tasks = taskService.asMemento().get();
    }
    
}

Last updated

Was this helpful?