Catching Wire; An introduction to CBWire 4

ortussolutions 22 views 39 slides May 14, 2025
Slide 1
Slide 1 of 39
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38
Slide 39
39

About This Presentation

Into the Box 2025 - Michael Rigsby

We are continually bombarded with the latest and greatest new (or at least new to us) “thing” and constantly told we should integrate this or that right away! Keeping up with new technologies, modules, libraries, etc. can be a full-time job in itself.

In this...


Slide Content

www.intothebox.org
LET’S GET STARTED
Build modern, reactive applications in record time without building backend APIs
CATCHING WIRE
WELCOME
Into the Box 2025: The Future is Dynamic!

www.intothebox.org
Stuck in legacy limbo? What if you
could evolve your coldboxapp
without breaking the bank or the
codebase?

www.intothebox.org
~ Dean Kamen
American engineer, inventor, and businessman
Inventor of theSegwayandiBOT
Every once in a while, a new
technology, an old problem, and a big
idea turn into an innovation.

Michael Rigsby
•Live in Severn Maryland with my wife, many dogs and one cat
•Multiple contributions to CBWIRE including Checksum and
Locked data properties
•Developing ColdFusion Apps since version 4.0 (since last century ;-)
Senior ColdFusion Developer
@[email protected] @mrigsby @michael.rigsby.9
Owner, OIS Technologies

Demo ColdBox App
https://github.com/mrigsby/CatchingWire

What is CBWIRE ?
CBWIRE is a ColdBox module utilizing Livewire.js and Alpine.js to
enable developers to create dynamic, interactive user interfaces
using all the benefits of the ColdBox MVC framework and reduces the
need for extensive JavaScript, making it easier for developers to build
responsive web applications without full page reloads, or building
new backend APIs.

Some Benefits of CBWIRE ?
CBWIRE simplifies development by leveraging
familiar CFML, offers real-time updates for a
responsive user experience, and optimizes
performance through efficient DOM updates. It also
integrates seamlessly with ColdBox, preserving form
states and reducing the learning curve for
developers
CBWire Simplifies Development

Some Benefits of CBWIRE ?
CBWIRE uses Livewire.js, developed for Laravel that
lets developers build dynamic web pages with less
JavaScript. Instead of writing complex client-side
code for tasks like updating the UI or handling form
submissions, Livewire.js handles the interaction with
the server. It automatically updates the DOM, so you
don’t need to write JavaScript for events or AJAX
calls, making development simpler and faster
No Need for Extensive Javascript

Some Benefits of CBWIRE ?
Alpine.js complements Livewire.js by helping to
handle client-side interactions, like real-time form
validation or toggling UI elements, without needing a
server request. This partnership reduces JavaScript
needs further, as Alpine.js is lightweight and easy to
use. Together, they offer responsive, instant
feedback, enhancing user experience and
performance.
Livewire.js includes Alpine.js

Some Benefits of CBWIRE ?
DOM morphing is a critical feature. It involves
comparing the current DOM in the browser with the
newly rendered HTML from the server after a
component update. Instead of replacing the entire
DOM, Livewire identifies differences and applies
surgical changes, preserving existing elements
including items such as event listeners, focus states,
and form input values.
DOM Morphing

www.intothebox.org
Anatomy of a “WIRE”
Wire Component (Model)
/wires/Counter1.cfc
Wire Template (View)
/wires/counter1.cfm
A “wire” is made up of a wire component and a
wire template.

www.intothebox.org
Anatomy of a “WIRE”
component extends="cbwire.models.Component"{
// Data properties
data = {
"counter": 0// default value
};
// Action
functionincrement(){
data.counter++;
}
}
Wire Component (Model)
/wires/Counter1.cfc

www.intothebox.org
Anatomy of a “WIRE”
<cfoutput>
<divclass="wireOuterWrapper">
<div>
Count: #counter#
</div>
<buttonwire:click="increment">+</button>
</div>
</cfoutput>
Wire Template (View)
/wires/counter1.cfm

www.intothebox.org
Anatomy of a “WIRE”
<cfoutput>
<divclass="wireOuterWrapper">
<div>
Count: #counter#
</div>
<buttonwire:click="increment">+</button>
</div>
</cfoutput>
Wire Template (View)
/wires/counter1.cfm

www.intothebox.org
Anatomy of a “WIRE”
<cfoutput>
<divclass="wireOuterWrapper">
<div>
Count: #counter#
</div>
<buttonwire:click="increment">+</button>
</div>
</cfoutput>
Wire Template (View)
/wires/counter1.cfm

www.intothebox.org
How do we use our “WIRE”?
<cfoutput>
#wire( "Counter1" )#
</cfoutput>
Place our wire in a ColdBox view or layout
/views/wiredemos/counter1.cfm

www.intothebox.org
What's Going On
CBWIRE Counter Component Interaction
D
R

T L R
R



R R S
S

L


D
D
RE



R
R
R

www.intothebox.org
What's Going On
CBWIRE Counter Component Interaction
D
R

T L R
R



R R S
S

L


D
D
RE



R
R
R

The user requests a page
from the server that
includes our Counter
component.
User Requests Page

www.intothebox.org
What's Going On
CBWIRE Counter Component Interaction
D
R

T L R
R



R R S
S

L


D
D
RE



R
R
R

#Wire(“counter1”)# is
handled by CBWire
ColdBox Receives Request

www.intothebox.org
What's Going On
CBWIRE Counter Component Interaction
D
R

T L R
R



R R S
S

L


D
D
RE



R
R
R

CBWIRE parses our
component and initially
renders it with its default
values.
CBWIRE Parses Component

www.intothebox.org
What's Going On
CBWIRE Counter Component Interaction
D
R

T L R
R



R R S
S

L


D
D
RE



R
R
R

The rendered component is
sent to the browser.
Note: that nothing extraordinary
has happened at this point.
Counter Displayed w/ Default
Values

www.intothebox.org
What's Going On
CBWIRE Counter Component Interaction
D
R

T L R
R



R R S
S

L


D
D
RE



R
R
R

CBWIRE uses Livewire.jsto
intercept the user's click
and send an XHR request
to the server.
User Clicks Button & Livewire.js
Intercepts Click

www.intothebox.org
What's Going On
CBWIRE Counter Component Interaction
D
R

T L R
R



R R S
S

L


D
D
RE



R
R
R

CBWIRE Handles the
request >>>
CBWIRE Intercepts the XHR Request
Sent to Server

www.intothebox.org
What's Going On
CBWIRE Counter Component Interaction
D
R

T L R
R



R R S
S

L


D
D
RE



R
R
R

CBWire hydrates the
Counter wire with data
from the request
Security! CBWIRE uses
both CSRF and Checksum
to validate the payload
being sent from browser
to server
CBWIRE Hydrates Counter

www.intothebox.org
What's Going On
CBWIRE Counter Component Interaction
D
R

T L R
R



R R S
S

L


D
D
RE



R
R
R

CBWIRE runs the
increment() method,
updating the data
properties.
CBWIRE Runs increment() method

www.intothebox.org
What's Going On
CBWIRE Counter Component Interaction
D
R

T L R
R



R R S
S

L


D
D
RE



R
R
R

CBWIRE re-renders the
template and returns
HTML to the browser in the
payload
CBWIRE Re-renders Counter and
HTML is returned

www.intothebox.org
What's Going On
CBWIRE Counter Component Interaction
D
R

T L R
R



R R S
S

L


D
D
RE



R
R
R

CBWIRE uses Livewire.js
DOM diffing to update the
component on the page.
CBWIRE Updates DOM for Counter1

www.intothebox.org
What's Going On
CBWIRE Counter Component Interaction
D
R

T L R
R



R R S
S

L


D
D
RE



R
R
R

www.intothebox.org
Under the Hood
{
"_token": "DC6FDBDF94A5957BDF486248A62A36673B0C6DB8" ,
"components": [
{
"snapshot": "{\"data\":{\"counter\":0},\"memo\":{\"id\":\"7ec78e2fb579c6913a04970fb7c10988
"updates": {},
"calls": [
{ "path": "", "method": "increment", "params": [] }
]
}
]
}
What is sent to the server for CBWIRE to parse?
Wire Payload

www.intothebox.org
Under the Hood
{
"_token": "DC6FDBDF94A5957BDF486248A62A36673B0C6DB8" ,
"components": [
{
"snapshot": "{\"data\":{\"counter\":0},\"memo\":{\"id\":\"7ec78e2fb579c6913a04970fb7c10988
"updates": {},
"calls": [
{ "path": "", "method": "increment", "params": [] }
]
}
]
}
What is sent to the server for CBWIRE to parse?
Wire Payload

www.intothebox.org
Under the Hood
{
"_token": "DC6FDBDF94A5957BDF486248A62A36673B0C6DB8" ,
"components": [
{
"snapshot": "{\"data\":{\"counter\":0},\"memo\":{\"id\":\"7ec78e2fb579c6913a04970fb7c10988
"updates": {},
"calls": [
{ "path": "", "method": "increment", "params": [] }
]
}
]
}
What is sent to the server for CBWIRE to parse?
Wire Payload

www.intothebox.org
Under the Hood
{
"data": { "counter": 0},
”memo": {
"id": "7ec78e2fb579c6913a04970fb7c10988" ,
"name": "Counter1",
"path": "Counter1",
"method": "GET",
"children": [],
"scripts": [],
"assets": [],
"isolate": false,
"lazyLoaded": false,
"lazyIsolated": true,
"errors": [],
"locale": "en"
},
"checksum": "f9f66fa895026e389a10ce006daf3f59afaec8db50cdb60f152af599b32f9192"
}
What is in the Snapshot?
Payload Snapshot

www.intothebox.org
Under the Hood
{
"data": { "counter": 0},
”memo": {
"id": "7ec78e2fb579c6913a04970fb7c10988" ,
"name": "Counter1",
"path": "Counter1",
"method": "GET",
"children": [],
"scripts": [],
"assets": [],
"isolate": false,
"lazyLoaded": false,
"lazyIsolated": true,
"errors": [],
"locale": "en"
},
"checksum": "f9f66fa895026e389a10ce006daf3f59afaec8db50cdb60f152af599b32f9192"
}
What is in the Snapshot?
Payload Snapshot
EST RA T E! D ’

to the client and passed back and forth
between the browser and server

www.intothebox.org
Under the Hood
{
"components": [
{
"snapshot": "{\"data\":{\"counter\":1},\"memo\":{\"id\":\"7ec78e2fb579c6913a04970fb7c10988 \
"effects": {
"html": "<div wire:id=\"7ec78e2fb579c6913a04970fb7c10988 \"class=\"wireOuterWrapper
"returns": [ null ]
}
}
]
}
What is returned from the server for Livewire.jsto parse?
CBWire Response

www.intothebox.org
Under the Hood
{
"components": [
{
"snapshot": "{\"data\":{\"counter\":1},\"memo\":{\"id\":\"7ec78e2fb579c6913a04970fb7c10988 \
"effects": {
"html": "<div wire:id=\"7ec78e2fb579c6913a04970fb7c10988 \"class=\"wireOuterWrapper
"returns": [ null ]
}
}
]
}
What is returned from the server for Livewire.jsto parse?
CBWire Response

www.intothebox.org
Under the Hood
{
"components": [
{
"snapshot": "{\"data\":{\"counter\":1},\"memo\":{\"id\":\"7ec78e2fb579c6913a04970fb7c10988 \
"effects": {
"html": "<div wire:id=\"7ec78e2fb579c6913a04970fb7c10988 \"class=\"wireOuterWrapper
"returns": [ null ]
}
}
]
}
What is returned from the server for Livewire.jsto parse?
CBWire Response

Let’s See It In Action
https://github.com/mrigsby/CatchingWire

www.intothebox.org
Just Scratching The Surface
➢More Template Directives
➢Single file wires
➢Alpine.jsspecific functionality
➢Cached Actions, AKA Computed Properties
➢Nesting Wires
➢Lazy Loading
➢AND MORE…
Some things I didn’t go into:

Thank You!
The Future of Modern Development Starts Here, with you!