SlideShare a Scribd company logo
Copyright © 2016 M/Gateway Developments Ltd
EWD 3 Training Course
Part 39
Building a React.js-based
QEWD Application
(c) Separating Concerns
Rob Tweed
Director, M/Gateway Developments Ltd
Twitter: @rtweed
Copyright © 2016 M/Gateway Developments Ltd
"use strict"
var React = require('react');
var displayText = '';
var MainPage = React.createClass({
getInitialState: function() {
return {
status: 'initial',
}
},
componentWillMount: function() {
this.props.controller.log = true;
var message = {
type: 'testMessage',
params: {
foo: 'bar'
}
};
var component = this;
this.props.controller.send(message, function(responseObj) {
displayText = responseObj.message.text;
component.setState({status: 'updated'});
});
},
render: function() {
console.log('rendering MainPage');
return (
<div>{displayText}</div>
);
}
});
module.exports = MainPage;
Copyright © 2016 M/Gateway Developments Ltd
Separation of Concerns
• Currently they aren't separated
– The dynamic behaviour and its associated
controlling logic is all included in the
MainPage component
– MainPage should ideally just describe the
View logic
Copyright © 2016 M/Gateway Developments Ltd
"use strict"
var React = require('react');
var controller;
var MainPage = React.createClass({
getInitialState: function() {
return {
status: 'initial',
}
},
componentWillMount: function() {
controller = require('./MainPage-controller')(this.props.controller, this);
},
render: function() {
console.log('rendering MainPage');
return (
<div>{this.displayText}</div>
);
}
});
module.exports = MainPage;
MainPage.js
Copyright © 2016 M/Gateway Developments Ltd
"use strict"
var React = require('react');
var controller;
var MainPage = React.createClass({
getInitialState: function() {
return {
status: 'initial',
}
},
componentWillMount: function() {
controller = require('./MainPage-controller')(this.props.controller, this);
},
render: function() {
console.log('rendering MainPage');
return (
<div>{this.displayText}</div>
);
}
});
module.exports = MainPage;
MainPage.js
Now describes only the
View for our component
Copyright © 2016 M/Gateway Developments Ltd
"use strict"
var React = require('react');
var controller;
var MainPage = React.createClass({
getInitialState: function() {
return {
status: 'initial',
}
},
componentWillMount: function() {
controller = require('./MainPage-controller')(this.props.controller, this);
},
render: function() {
console.log('rendering MainPage');
return (
<div>{ this.displayText }</div>
);
}
});
module.exports = MainPage;
MainPage.js
Now describes only the
View for our component
displayText is now a
property of this, not
a variable that has to
be instantiated in the
component itself
Copyright © 2016 M/Gateway Developments Ltd
"use strict"
var React = require('react');
var controller;
var MainPage = React.createClass({
getInitialState: function() {
return {
status: 'initial',
}
},
componentWillMount: function() {
controller = require('./MainPage-controller')(this.props.controller, this);
},
render: function() {
console.log('rendering MainPage');
return (
<div>{this.displayText}</div>
);
}
});
module.exports = MainPage;
MainPage.js
Now describes only the
View for our component
Dynamic behaviour is
now described in a
separate module that
we load into the MainPage
Component here
Copyright © 2016 M/Gateway Developments Ltd
"use strict"
var React = require('react');
var controller;
var MainPage = React.createClass({
getInitialState: function() {
return {
status: 'initial',
}
},
componentWillMount: function() {
controller = require('./MainPage-controller')(this.props.controller, this);
},
render: function() {
console.log('rendering MainPage');
return (
<div>{this.displayText}</div>
);
}
});
module.exports = MainPage;
MainPage.js
Now describes only the
View for our component
State is still the concern
of MainPage, but it's just
for triggering re-renders
Copyright © 2016 M/Gateway Developments Ltd
MainPage-controller.js
module.exports = function (controller, component) {
// describe the Component's dynamic behaviour
return controller;
};
Copyright © 2016 M/Gateway Developments Ltd
MainPage-controller.js
module.exports = function (controller, component) {
// describe the Component's dynamic behaviour
return controller;
};
Invoked by the parent component like this:
componentWillMount: function() {
controller = require('./MainPage-controller')(this.props.controller, this);
},
Copyright © 2016 M/Gateway Developments Ltd
MainPage-controller.js
module.exports = function (controller, component) {
// describe the Component's dynamic behaviour
return controller;
};
Invoked by the parent component like this:
componentWillMount: function() {
controller = require('./MainPage-controller')(this.props.controller, this);
},
Copyright © 2016 M/Gateway Developments Ltd
MainPage-controller.js
module.exports = function (controller, component) {
// describe the Component's dynamic behaviour
return controller;
};
Invoked by the parent component like this:
componentWillMount: function() {
controller = require('./MainPage-controller')(this.props.controller, this);
},
Copyright © 2016 M/Gateway Developments Ltd
MainPage-controller.js
module.exports = function (controller, component) {
// describe the Component's dynamic behaviour
return controller;
};
Invoked by the parent component like this:
componentWillMount: function() {
controller = require('./MainPage-controller')(this.props.controller, this);
},
New augmented instance
Copyright © 2016 M/Gateway Developments Ltd
"use strict"
var React = require('react');
var displayText = '';
var MainPage = React.createClass({
getInitialState: function() {
return {
status: 'initial',
}
},
componentWillMount: function() {
this.props.controller.log = true;
var message = {
type: 'testMessage',
params: {
foo: 'bar'
}
};
var component = this;
this.props.controller.send(message, function(responseObj) {
displayText = responseObj.message.text;
component.setState({status: 'updated'});
});
},
render: function() {
console.log('rendering MainPage');
return (
<div>{displayText}</div>
);
}
});
module.exports = MainPage;
This was our original
Component's logic
We need to move the
code in red into the
Controller module
Copyright © 2016 M/Gateway Developments Ltd
MainPage-controller.js
module.exports = function (controller, component) {
component.displayText = '';
controller.log = true;
var message = {
type: 'testMessage',
params: {
foo: 'bar'
}
};
controller.send(message, function(responseObj) {
component.displayText = responseObj.message.text;
component.setState({status: 'updated'});
});
return controller;
};
Copyright © 2016 M/Gateway Developments Ltd
MainPage-controller.js
module.exports = function (controller, component) {
component.displayText = '';
controller.log = true;
var message = {
type: 'testMessage',
params: {
foo: 'bar'
}
};
controller.send(message, function(responseObj) {
component.displayText = responseObj.message.text;
component.setState({status: 'updated'});
});
return controller;
};
Initialising and changing
the value of
this.displayText in the
parent component
Copyright © 2016 M/Gateway Developments Ltd
MainPage-controller.js
module.exports = function (controller, component) {
component.displayText = '';
controller.log = true;
var message = {
type: 'testMessage',
params: {
foo: 'bar'
}
};
controller.send(message, function(responseObj) {
component.displayText = responseObj.message.text;
component.setState({status: 'updated'});
});
return controller;
};
Changing the parent
component's state
variable value to
trigger a re-render
Copyright © 2016 M/Gateway Developments Ltd
Re-bundle and try it again
It will run exactly
the same as before
Copyright © 2016 M/Gateway Developments Ltd
Pattern for Development
• The pattern we've created can be adopted for all of your
components and sub-components
• It cleanly separates the concerns:
– View: the parent component
– Dynamic behaviour: the controller module
• There are alternatives in the React world:
– Flux, Redux, etc
– These can also be used with QEWD
• Worth exploring when you're more familiar with the concepts
within React
• Let's use the simpler pattern described in this part of the
QEWD course for now

More Related Content

PDF
EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 4
PDF
EWD 3 Training Course Part 41: Building a React.js application with QEWD, Part 5
PDF
EWD 3 Training Course Part 16: QEWD Services
PDF
EWD 3 Training Course Part 13: Putting Everything so far into Practice using ...
PDF
EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 2
PDF
EWD 3 Training Course Part 14: Using Ajax for QEWD Messages
PDF
EWD 3 Training Course Part 37: Building a React.js application with ewd-xpres...
PDF
EWD 3 Training Course Part 5b: First Steps in Building a QEWD Application
EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 4
EWD 3 Training Course Part 41: Building a React.js application with QEWD, Part 5
EWD 3 Training Course Part 16: QEWD Services
EWD 3 Training Course Part 13: Putting Everything so far into Practice using ...
EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 2
EWD 3 Training Course Part 14: Using Ajax for QEWD Messages
EWD 3 Training Course Part 37: Building a React.js application with ewd-xpres...
EWD 3 Training Course Part 5b: First Steps in Building a QEWD Application

What's hot (20)

PDF
EWD 3 Training Course Part 36: Accessing REST and Web Services from a QEWD ap...
PDF
EWD 3 Training Course Part 7: Applying the QEWD Messaging Pattern
PDF
EWD 3 Training Course Part 5a: First Steps in Building a QEWD Application
PDF
EWD 3 Training Course Part 2: EWD 3 Overview
PDF
EWD 3 Training Course Part 4: Installing & Configuring QEWD
PDF
EWD 3 Training Course Part 11: Handling Errors in QEWD
PDF
EWD 3 Training Course Part 30: Modularising QEWD Applications
PPT
EWD 3 Training Course Part 43: Using JSON Web Tokens with QEWD REST Services
PDF
EWD 3 Training Course Part 29: Running QEWD as a Service
PDF
EWD 3 Training Course Part 10: QEWD Sessions and User Authentication
PDF
EWD 3 Training Course Part 12: QEWD Session Timeout Control
PDF
EWD 3 Training Course Part 27: The QEWD Session
PDF
EWD 3 Training Course Part 19: The cache.node APIs
PDF
EWD 3 Training Course Part 28: Integrating Legacy Mumps Code with QEWD
PPT
EWD 3 Training Course Part 44: Creating MicroServices with QEWD.js
PDF
EWD 3 Training Course Part 6: What Happens when a QEWD Application is Started
PPT
EWD 3 Training Course Part 45: Using QEWD's Advanced MicroService Functionality
PDF
EWD 3 Training Course Part 35: QEWD Session Locking
PPT
EWD 3 Training Course Part 31: Using QEWD for Web and REST Services
EWD 3 Training Course Part 36: Accessing REST and Web Services from a QEWD ap...
EWD 3 Training Course Part 7: Applying the QEWD Messaging Pattern
EWD 3 Training Course Part 5a: First Steps in Building a QEWD Application
EWD 3 Training Course Part 2: EWD 3 Overview
EWD 3 Training Course Part 4: Installing & Configuring QEWD
EWD 3 Training Course Part 11: Handling Errors in QEWD
EWD 3 Training Course Part 30: Modularising QEWD Applications
EWD 3 Training Course Part 43: Using JSON Web Tokens with QEWD REST Services
EWD 3 Training Course Part 29: Running QEWD as a Service
EWD 3 Training Course Part 10: QEWD Sessions and User Authentication
EWD 3 Training Course Part 12: QEWD Session Timeout Control
EWD 3 Training Course Part 27: The QEWD Session
EWD 3 Training Course Part 19: The cache.node APIs
EWD 3 Training Course Part 28: Integrating Legacy Mumps Code with QEWD
EWD 3 Training Course Part 44: Creating MicroServices with QEWD.js
EWD 3 Training Course Part 6: What Happens when a QEWD Application is Started
EWD 3 Training Course Part 45: Using QEWD's Advanced MicroService Functionality
EWD 3 Training Course Part 35: QEWD Session Locking
EWD 3 Training Course Part 31: Using QEWD for Web and REST Services
Ad

Viewers also liked (13)

PDF
EWD 3 Training Course Part 22: Traversing Documents using DocumentNode Objects
PDF
EWD 3 Training Course Part 26: Event-driven Indexing
PDF
EWD 3 Training Course Part 23: Traversing a Range using DocumentNode Objects
PPT
Mumps the Internet scale database
PDF
EWD 3 Training Course Part 18: Modelling NoSQL Databases using Global Storage
PDF
EWD 3 Training Course Part 25: Document Database Capabilities
PDF
EWD 3 Training Course Part 24: Traversing a Document's Leaf Nodes
PDF
EWD 3 Training Course Part 21: Persistent JavaScript Objects
PDF
EWD 3 Training Course Part 20: The DocumentNode Object
PDF
EWD 3 Training Course Part 32: Configuring QEWD to use SSL/HTTPS
PDF
EWD 3 Training Course Part 34: QEWD Resilient Mode
PPT
EWD 3 Training Course Part 42: The QEWD Docker Appliance
PDF
EWD 3 Training Course Part 33: Configuring QEWD to use CORS
EWD 3 Training Course Part 22: Traversing Documents using DocumentNode Objects
EWD 3 Training Course Part 26: Event-driven Indexing
EWD 3 Training Course Part 23: Traversing a Range using DocumentNode Objects
Mumps the Internet scale database
EWD 3 Training Course Part 18: Modelling NoSQL Databases using Global Storage
EWD 3 Training Course Part 25: Document Database Capabilities
EWD 3 Training Course Part 24: Traversing a Document's Leaf Nodes
EWD 3 Training Course Part 21: Persistent JavaScript Objects
EWD 3 Training Course Part 20: The DocumentNode Object
EWD 3 Training Course Part 32: Configuring QEWD to use SSL/HTTPS
EWD 3 Training Course Part 34: QEWD Resilient Mode
EWD 3 Training Course Part 42: The QEWD Docker Appliance
EWD 3 Training Course Part 33: Configuring QEWD to use CORS
Ad

Similar to EWD 3 Training Course Part 39: Building a React.js application with QEWD, Part 3 (20)

PPTX
Getting started with react &amp; redux
PDF
The road-to-learn-react
PDF
An Introduction to React -- FED Date -- IBM Design
PDF
React lecture
PDF
Let's discover React and Redux with TypeScript
PDF
Redux Deep Dive - ReactFoo Pune 2018
PPTX
The productive developer guide to React
PDF
Why react matters
PPTX
Introduction to React JS
PPTX
React JS: A Secret Preview
PDF
React Native +Redux + ES6 (Updated)
PDF
Stay with React.js in 2020
PPTX
[Final] ReactJS presentation
PPTX
React & Redux for noobs
PPTX
Maintaining sanity in a large redux app
PPTX
Battle of React State Managers in frontend applications
PDF
Tokyo React.js #3: Missing Pages: ReactJS/Flux/GraphQL/RelayJS
PPTX
React Workshop: Core concepts of react
PDF
Integrating React.js with PHP projects
PPTX
Redux training
Getting started with react &amp; redux
The road-to-learn-react
An Introduction to React -- FED Date -- IBM Design
React lecture
Let's discover React and Redux with TypeScript
Redux Deep Dive - ReactFoo Pune 2018
The productive developer guide to React
Why react matters
Introduction to React JS
React JS: A Secret Preview
React Native +Redux + ES6 (Updated)
Stay with React.js in 2020
[Final] ReactJS presentation
React & Redux for noobs
Maintaining sanity in a large redux app
Battle of React State Managers in frontend applications
Tokyo React.js #3: Missing Pages: ReactJS/Flux/GraphQL/RelayJS
React Workshop: Core concepts of react
Integrating React.js with PHP projects
Redux training

More from Rob Tweed (7)

PDF
QEWD Update
PPT
Data Persistence as a Language Feature
PPT
LNUG: Having Your Node.js Cake and Eating It Too
PPT
QEWD.js, JSON Web Tokens & MicroServices
PPT
QEWD.js: Have your Node.js Cake and Eat It Too
PPT
ewd-qoper8-vistarpc: Exposing VistA's RPCs as REST Services
PDF
qewd-ripple: The Ripple OSI Middle Tier
QEWD Update
Data Persistence as a Language Feature
LNUG: Having Your Node.js Cake and Eating It Too
QEWD.js, JSON Web Tokens & MicroServices
QEWD.js: Have your Node.js Cake and Eat It Too
ewd-qoper8-vistarpc: Exposing VistA's RPCs as REST Services
qewd-ripple: The Ripple OSI Middle Tier

Recently uploaded (20)

PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PPTX
history of c programming in notes for students .pptx
PDF
System and Network Administraation Chapter 3
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
System and Network Administration Chapter 2
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PPTX
Computer Software and OS of computer science of grade 11.pptx
PDF
Softaken Excel to vCard Converter Software.pdf
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PPT
Introduction Database Management System for Course Database
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PPTX
Introduction to Artificial Intelligence
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
Understanding Forklifts - TECH EHS Solution
PDF
Digital Strategies for Manufacturing Companies
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Wondershare Filmora 15 Crack With Activation Key [2025
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Design an Analysis of Algorithms I-SECS-1021-03
history of c programming in notes for students .pptx
System and Network Administraation Chapter 3
CHAPTER 2 - PM Management and IT Context
System and Network Administration Chapter 2
wealthsignaloriginal-com-DS-text-... (1).pdf
Computer Software and OS of computer science of grade 11.pptx
Softaken Excel to vCard Converter Software.pdf
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Introduction Database Management System for Course Database
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Introduction to Artificial Intelligence
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
How to Migrate SBCGlobal Email to Yahoo Easily
Odoo Companies in India – Driving Business Transformation.pdf
Understanding Forklifts - TECH EHS Solution
Digital Strategies for Manufacturing Companies
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025

EWD 3 Training Course Part 39: Building a React.js application with QEWD, Part 3

  • 1. Copyright © 2016 M/Gateway Developments Ltd EWD 3 Training Course Part 39 Building a React.js-based QEWD Application (c) Separating Concerns Rob Tweed Director, M/Gateway Developments Ltd Twitter: @rtweed
  • 2. Copyright © 2016 M/Gateway Developments Ltd "use strict" var React = require('react'); var displayText = ''; var MainPage = React.createClass({ getInitialState: function() { return { status: 'initial', } }, componentWillMount: function() { this.props.controller.log = true; var message = { type: 'testMessage', params: { foo: 'bar' } }; var component = this; this.props.controller.send(message, function(responseObj) { displayText = responseObj.message.text; component.setState({status: 'updated'}); }); }, render: function() { console.log('rendering MainPage'); return ( <div>{displayText}</div> ); } }); module.exports = MainPage;
  • 3. Copyright © 2016 M/Gateway Developments Ltd Separation of Concerns • Currently they aren't separated – The dynamic behaviour and its associated controlling logic is all included in the MainPage component – MainPage should ideally just describe the View logic
  • 4. Copyright © 2016 M/Gateway Developments Ltd "use strict" var React = require('react'); var controller; var MainPage = React.createClass({ getInitialState: function() { return { status: 'initial', } }, componentWillMount: function() { controller = require('./MainPage-controller')(this.props.controller, this); }, render: function() { console.log('rendering MainPage'); return ( <div>{this.displayText}</div> ); } }); module.exports = MainPage; MainPage.js
  • 5. Copyright © 2016 M/Gateway Developments Ltd "use strict" var React = require('react'); var controller; var MainPage = React.createClass({ getInitialState: function() { return { status: 'initial', } }, componentWillMount: function() { controller = require('./MainPage-controller')(this.props.controller, this); }, render: function() { console.log('rendering MainPage'); return ( <div>{this.displayText}</div> ); } }); module.exports = MainPage; MainPage.js Now describes only the View for our component
  • 6. Copyright © 2016 M/Gateway Developments Ltd "use strict" var React = require('react'); var controller; var MainPage = React.createClass({ getInitialState: function() { return { status: 'initial', } }, componentWillMount: function() { controller = require('./MainPage-controller')(this.props.controller, this); }, render: function() { console.log('rendering MainPage'); return ( <div>{ this.displayText }</div> ); } }); module.exports = MainPage; MainPage.js Now describes only the View for our component displayText is now a property of this, not a variable that has to be instantiated in the component itself
  • 7. Copyright © 2016 M/Gateway Developments Ltd "use strict" var React = require('react'); var controller; var MainPage = React.createClass({ getInitialState: function() { return { status: 'initial', } }, componentWillMount: function() { controller = require('./MainPage-controller')(this.props.controller, this); }, render: function() { console.log('rendering MainPage'); return ( <div>{this.displayText}</div> ); } }); module.exports = MainPage; MainPage.js Now describes only the View for our component Dynamic behaviour is now described in a separate module that we load into the MainPage Component here
  • 8. Copyright © 2016 M/Gateway Developments Ltd "use strict" var React = require('react'); var controller; var MainPage = React.createClass({ getInitialState: function() { return { status: 'initial', } }, componentWillMount: function() { controller = require('./MainPage-controller')(this.props.controller, this); }, render: function() { console.log('rendering MainPage'); return ( <div>{this.displayText}</div> ); } }); module.exports = MainPage; MainPage.js Now describes only the View for our component State is still the concern of MainPage, but it's just for triggering re-renders
  • 9. Copyright © 2016 M/Gateway Developments Ltd MainPage-controller.js module.exports = function (controller, component) { // describe the Component's dynamic behaviour return controller; };
  • 10. Copyright © 2016 M/Gateway Developments Ltd MainPage-controller.js module.exports = function (controller, component) { // describe the Component's dynamic behaviour return controller; }; Invoked by the parent component like this: componentWillMount: function() { controller = require('./MainPage-controller')(this.props.controller, this); },
  • 11. Copyright © 2016 M/Gateway Developments Ltd MainPage-controller.js module.exports = function (controller, component) { // describe the Component's dynamic behaviour return controller; }; Invoked by the parent component like this: componentWillMount: function() { controller = require('./MainPage-controller')(this.props.controller, this); },
  • 12. Copyright © 2016 M/Gateway Developments Ltd MainPage-controller.js module.exports = function (controller, component) { // describe the Component's dynamic behaviour return controller; }; Invoked by the parent component like this: componentWillMount: function() { controller = require('./MainPage-controller')(this.props.controller, this); },
  • 13. Copyright © 2016 M/Gateway Developments Ltd MainPage-controller.js module.exports = function (controller, component) { // describe the Component's dynamic behaviour return controller; }; Invoked by the parent component like this: componentWillMount: function() { controller = require('./MainPage-controller')(this.props.controller, this); }, New augmented instance
  • 14. Copyright © 2016 M/Gateway Developments Ltd "use strict" var React = require('react'); var displayText = ''; var MainPage = React.createClass({ getInitialState: function() { return { status: 'initial', } }, componentWillMount: function() { this.props.controller.log = true; var message = { type: 'testMessage', params: { foo: 'bar' } }; var component = this; this.props.controller.send(message, function(responseObj) { displayText = responseObj.message.text; component.setState({status: 'updated'}); }); }, render: function() { console.log('rendering MainPage'); return ( <div>{displayText}</div> ); } }); module.exports = MainPage; This was our original Component's logic We need to move the code in red into the Controller module
  • 15. Copyright © 2016 M/Gateway Developments Ltd MainPage-controller.js module.exports = function (controller, component) { component.displayText = ''; controller.log = true; var message = { type: 'testMessage', params: { foo: 'bar' } }; controller.send(message, function(responseObj) { component.displayText = responseObj.message.text; component.setState({status: 'updated'}); }); return controller; };
  • 16. Copyright © 2016 M/Gateway Developments Ltd MainPage-controller.js module.exports = function (controller, component) { component.displayText = ''; controller.log = true; var message = { type: 'testMessage', params: { foo: 'bar' } }; controller.send(message, function(responseObj) { component.displayText = responseObj.message.text; component.setState({status: 'updated'}); }); return controller; }; Initialising and changing the value of this.displayText in the parent component
  • 17. Copyright © 2016 M/Gateway Developments Ltd MainPage-controller.js module.exports = function (controller, component) { component.displayText = ''; controller.log = true; var message = { type: 'testMessage', params: { foo: 'bar' } }; controller.send(message, function(responseObj) { component.displayText = responseObj.message.text; component.setState({status: 'updated'}); }); return controller; }; Changing the parent component's state variable value to trigger a re-render
  • 18. Copyright © 2016 M/Gateway Developments Ltd Re-bundle and try it again It will run exactly the same as before
  • 19. Copyright © 2016 M/Gateway Developments Ltd Pattern for Development • The pattern we've created can be adopted for all of your components and sub-components • It cleanly separates the concerns: – View: the parent component – Dynamic behaviour: the controller module • There are alternatives in the React world: – Flux, Redux, etc – These can also be used with QEWD • Worth exploring when you're more familiar with the concepts within React • Let's use the simpler pattern described in this part of the QEWD course for now