CBWIRE
InstallSource CodeIssuesSupport
v3.x
v3.x
  • Introduction
  • Getting Started
  • Configuration
  • How It Works
  • Release History
    • What's New With 3.2
    • What's New With 3.1
    • What's New With 3.0
    • What's New With 2.2
    • What's New With 2.1
    • What's New With 2.0
  • Examples
    • Contact Form
    • Multi-select Input
    • File Upload
  • Resources
  • The Essentials
    • Components
    • Templates
    • Data Properties
    • Computed Properties
    • Actions
    • Events
    • Lifecycle Methods
    • JavaScript
    • Testing
  • Wire Features
    • Validation
    • File Uploads
    • Query String
    • Redirecting
    • WireBox
  • Template Features
    • Directives
    • Loading States
    • Polling
    • Prefetching
    • Offline State
    • Defer Loading
    • Dirty State
  • Integrations
    • ContentBox CMS
    • SPAs with Turbo
    • AlpineJS
Powered by GitBook
On this page
  • getInstance()
  • Property Injection
  • onDIComplete
  1. Wire Features

WireBox

ColdBox's dependency injection framework, right there when you need it.

CBWIRE includes WireBox for pulling any dependencies you may need to use in your components, such as service objects, settings, and more.

getInstance()

You can pull in dependencies to your component using getInstance().

<cfscript>
    function log() {
        var storage = getInstance( "cbfs:disks:temp" );
        storage.create( "log.txt", "CBWIRE rocks!" );
    }
</cfscript>

<cfoutput>
    <div>
        <!--- HTML goes here --->
    </div>
</cfoutput>

Property Injection

You can also pull in dependencies using property injection.

<cfscript>
    property name="storage" inject="cbfs:disks:temp";

    function log() {
        storage.create( "log.txt", "CBWIRE rocks!" );
    }
</cfscript>

<cfoutput>
    <div>
        <!--- HTML goes here --->
    </div>
</cfoutput>

onDIComplete

If you want to act immediately after WireBox has fully constructor your component with it's dependencies, you can hook into the onDIComplete() method.

<cfscript>
    property name="storage" inject="cbfs:disks:temp";

    function onDIComplete() {
        log.info( "CBWIRE rocks!" );
    }
</cfscript>

<cfoutput>
    <div>
        <!--- HTML goes here --->
    </div>
</cfoutput>
PreviousRedirectingNextDirectives

Last updated 1 year ago