SlideShare une entreprise Scribd logo
1  sur  64
Télécharger pour lire hors ligne
components are the new
THIN CLIENT!
Story Time
DOM
jQuery “Application”
$( "form" ).submit(function( event ) {
if ( $( "input:first" ).val() === "correct" ) {
$( "span" ).text( "Validated..." ).show();
return;
}
$( "span" ).text( "Not valid!" ).show().fadeOut( 1000 );
event.preventDefault();
});
DOM
First Generation AngularJS Application
CONTROLLER
DOM
Second Generation AngularJS Application
CONTROLLER SERVICE
DOM CONTROLLER
Typical Stateful Service
Enter Redux
STOREREDUCERS
In classical physics, if you know everything about a
system at some instant of time, and you also know the
equations that govern how the system changes then you
can predict the future. That's what we mean when we say
that the classical laws of physics are deterministic. If we
can say the same thing, but with the past and future
reversed, the same equations tell you everything about
the past. Such a system is called reversible.
The Theoretical Minimum by Leonard Susskind
In classical physics, if you know everything about a
system at some instant of time, and you also know the
equations that govern how the system changes then you
can predict the future. That's what we mean when we say
that the classical laws of physics are deterministic. If we
can say the same thing, but with the past and future
reversed, the same equations tell you everything about
the past. Such a system is called reversible.
The Theoretical Minimum by Leonard Susskind
STORE!
In classical physics, if you know everything about a
system at some instant of time, and you also know the
equations that govern how the system changes then you
can predict the future. That's what we mean when we say
that the classical laws of physics are deterministic. If we
can say the same thing, but with the past and future
reversed, the same equations tell you everything about
the past. Such a system is called reversible.
The Theoretical Minimum by Leonard Susskind
REDUCERS!
In classical physics, if you know everything about a
system at some instant of time, and you also know the
equations that govern how the system changes then you
can predict the future. That's what we mean when we say
that the classical laws of physics are deterministic. If we
can say the same thing, but with the past and future
reversed, the same equations tell you everything about
the past. Such a system is called reversible.
The Theoretical Minimum by Leonard Susskind
In classical physics, if you know everything about a
system at some instant of time, and you also know the
equations that govern how the system changes then you
can predict the future. That's what we mean when we say
that the classical laws of physics are deterministic. If we
can say the same thing, but with the past and future
reversed, the same equations tell you everything about
the past. Such a system is called reversible.
The Theoretical Minimum by Leonard Susskind
User Input and Response
Time and Space
ACTIONS!
Space: Manual Dispatch
CLICK
DISPATCH
actions = [
{type: '[Client] Select', payload: {id: '1', firstName: 'John', lastName: 'Doe', company: 'Acme, Inc'}},
{type: '[Client] Select', payload: {id: '2', firstName: 'Jane', lastName: 'Smith', company: 'Super, Inc'}},
{type: '[Client] Select', payload: {id: '1', firstName: 'John', lastName: 'Doe', company: 'Acme, Inc'}},
{type: '[Client] Select', payload: {id: '2', firstName: 'Jane', lastName: 'Smith', company: 'Super, Inc'}},
{type: '[Client] Select', payload: {id: '1', firstName: 'John', lastName: 'Doe', company: 'Acme, Inc'}},
{type: '[Client] Select', payload: {id: '2', firstName: 'Jane', lastName: 'Smith', company: 'Super, Inc'}},
];
index = 0;
step() {
this.index = this.index < this.actions.length - 1 ? this.index + 1 : 0;
this.store.dispatch(this.actions[this.index]);
}
Manual Dispatch
DEMO TIME!
Time: Manual Cycle
CLICK
DISPATCH
actions = [
{type: '[Client] Select', payload: {id: '1', firstName: 'John', lastName: 'Doe', company: 'Acme, Inc'}},
{type: '[Client] Select', payload: {id: '2', firstName: 'Jane', lastName: 'Smith', company: 'Super, Inc'}},
{type: '[Client] Select', payload: {id: '1', firstName: 'John', lastName: 'Doe', company: 'Acme, Inc'}},
{type: '[Client] Select', payload: {id: '2', firstName: 'Jane', lastName: 'Smith', company: 'Super, Inc'}},
{type: '[Client] Select', payload: {id: '1', firstName: 'John', lastName: 'Doe', company: 'Acme, Inc'}},
{type: '[Client] Select', payload: {id: '2', firstName: 'Jane', lastName: 'Smith', company: 'Super, Inc'}},
];
cycle() {
const result = Observable
.from(this.actions)
.zip(Observable.interval(this.timerInterval), (a, b) => a)
;
result.subscribe(action => this.store.dispatch(action));
}
Manual Cycle
DEMO TIME!
Space: Dynamic Dispatch
SUBMIT
CLICK
DISPATCH
fetchSingle() {
this.actionsService
.single()
.subscribe(action => this.action = JSON.stringify(action, null , 't'));
}
dispatch(action) {
this.store.dispatch(JSON.parse(action));
}
Dynamic Dispatch
DEMO TIME!
Time: Dynamic Cycle
SUBMIT
CLICK
DISPATCH
fetchAll() {
this.actionsService
.all()
.subscribe(actions => this.rawActions = JSON.stringify(actions, null , 't'));
}
dispatchCycle(rawActions) {
const actions = JSON.parse(rawActions);
const result = Observable
.from(actions)
.zip(Observable.interval(this.timerInterval), (a, b) => a)
;
result.subscribe((action: any) => this.store.dispatch(action));
}
Dynamic Dispatch
DEMO TIME!
Space: Remote Dispatch
constructor(
private actionsService: ActionsService,
private store: Store<reducers.AppState>,
private afs: AngularFirestore
) {
this.remoteActions = afs.collection('actions');
}
ngOnInit() {
this.remoteActions.valueChanges()
.skip(1)
.subscribe((actions: any) => {
this.store.dispatch(actions[0]);
});
}
dispatchRemote(action) {
this.remoteActions.add(JSON.parse(action));
}
Remote Dispatch
DEMO TIME!
Time: Undo and Redo
export function undoable(reducer: ActionReducer<any>): ActionReducer<any> {
// Call the reducer with empty action to populate the initial state
const initialState = {
past: [],
present: reducer(undefined, { type: ''}),
future: []
};
// Return a reducer that handles undo and redo
return function (state = initialState, action) {
const { past, present, future } = state;
switch (action.type) {
case 'UNDO':
// UNDO LOGIC
case 'REDO':
// REDO LOGIC
default:
// REGULAR LOGIC
}
};
}
Meta Reducer
DEMO TIME!
REAL WORLD APPLICATIONS
Redux Airbrake
https://www.npmjs.com/package/redux-airbrake
@castillo__io
BONUS SLIDE!
Space and Time:
Thin Component
const CLIENT_LOAD = '[Client] Load';
const CLIENT_CREATE = '[Client] Create';
const CLIENT_UPDATE = '[Client] Update';
const CLIENT_DELETE = '[Client] Delete';
const CLIENT_SELECT = '[Client] Select';
const CLIENT_CLEAR = '[Client] Clear';
Actions
const reducer = (state = initialState, {type, payload}) => {
switch (type) {
case CLIENT_LOAD:
return state;
case CLIENT_SELECT:
return selectClient(state, payload);
case CLIENT_CREATE:
return createClient(state, payload);
case CLIENT_UPDATE:
return updateClient(state, payload);
case CLIENT_DELETE:
return deleteClient(state, payload);
case CLIENT_CLEAR:
return clearClient(state, payload);
default:
return state;
}
};
const store = new Store(reducer, initialState);
Reducer
export class ClientsComponent implements OnInit {
clients$: Observable<Client[]>;
currentClient$: Observable<Client>;
constructor(private store: Store) {
this.clients$ = this.store.select('clients');
this.currentClient$ = this.store.select('currentClient');
}
ngOnInit() {
this.store.dispatch(new ClientActions.LoadAction());
this.resetCurrentClient();
}
resetCurrentClient() {
const newClient: Client = { id: null, firstName: '', lastName: '', company: '' };
this.store.dispatch(new ClientActions.SelectAction(newClient));
}
}
ClientsComponent
class Store {
constructor(reducer) {
this.reducer = reducer;
this.state = reducer(undefined, { type: ''});
}
getState() {
return this.state.present;
}
dispatch(action) {
this.state = this.reducer(this.state, action);
}
}
Store
io.on('connection', (socket) => {
console.log('user connected');
io.emit('update', store.getState());
socket.on('dispatch', action => {
store.dispatch(action);
io.emit('update', store.getState());
});
socket.on('disconnect', function () {
console.log('user disconnected');
});
});
http.listen(5000, () => {
console.log('started on port 5000');
});
Socket.io
const BASE_URL = 'http://localhost:5000';
export class SocketService {
private socket;
private subjects = {};
constructor() {
this.socket = io(BASE_URL);
this.socket.on('update', data => this.next(data));
}
select(key) {
this.subjects[key] = new BehaviorSubject(null);
return this.subjects[key].asObservable();
}
next(data) {
for (const key in this.subjects) {
if (this.subjects.hasOwnProperty(key)) {
this.subjects[key].next(data[key]);
}
}
}
dispatch(action) {
this.socket.emit('dispatch', action);
}
}
SocketService
DEMO TIME!
https://github.com/onehungrymind/component-thin-clients
@simpulton
https://venturplex.com/
WE❤YOU!
Thanks!

Contenu connexe

Similaire à Components Are the New Thin Client

FITC Web Unleashed 2017 - Introduction to the World of Testing for Front-End ...
FITC Web Unleashed 2017 - Introduction to the World of Testing for Front-End ...FITC Web Unleashed 2017 - Introduction to the World of Testing for Front-End ...
FITC Web Unleashed 2017 - Introduction to the World of Testing for Front-End ...Haris Mahmood
 
Introduction to ECMAScript 2015
Introduction to ECMAScript 2015Introduction to ECMAScript 2015
Introduction to ECMAScript 2015Tomasz Dziuda
 
Drools Introduction
Drools IntroductionDrools Introduction
Drools IntroductionJBug Italy
 
React.js: Beyond the Browser
React.js: Beyond the BrowserReact.js: Beyond the Browser
React.js: Beyond the Browsergarbles
 
Getting started with Elasticsearch and .NET
Getting started with Elasticsearch and .NETGetting started with Elasticsearch and .NET
Getting started with Elasticsearch and .NETTomas Jansson
 
jRuby: The best of both worlds
jRuby: The best of both worldsjRuby: The best of both worlds
jRuby: The best of both worldsChristopher Spring
 
Message-based communication patterns in distributed Akka applications
Message-based communication patterns in distributed Akka applicationsMessage-based communication patterns in distributed Akka applications
Message-based communication patterns in distributed Akka applicationsAndrii Lashchenko
 
Javascript: the important bits
Javascript: the important bitsJavascript: the important bits
Javascript: the important bitsChris Saylor
 
10 Billion a Day, 100 Milliseconds Per: Monitoring Real-Time Bidding at AdRoll
10 Billion a Day, 100 Milliseconds Per: Monitoring Real-Time Bidding at AdRoll10 Billion a Day, 100 Milliseconds Per: Monitoring Real-Time Bidding at AdRoll
10 Billion a Day, 100 Milliseconds Per: Monitoring Real-Time Bidding at AdRollBrian Troutwine
 
Async Redux Actions With RxJS - React Rally 2016
Async Redux Actions With RxJS - React Rally 2016Async Redux Actions With RxJS - React Rally 2016
Async Redux Actions With RxJS - React Rally 2016Ben Lesh
 
Clean code in JavaScript
Clean code in JavaScriptClean code in JavaScript
Clean code in JavaScriptMathieu Breton
 
Buenos Aires Drools Expert Presentation
Buenos Aires Drools Expert PresentationBuenos Aires Drools Expert Presentation
Buenos Aires Drools Expert PresentationMark Proctor
 
Concurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STM
Concurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STMConcurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STM
Concurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STMMario Fusco
 
MongoDB World 2019: Life In Stitch-es
MongoDB World 2019: Life In Stitch-esMongoDB World 2019: Life In Stitch-es
MongoDB World 2019: Life In Stitch-esMongoDB
 
Event driven javascript
Event driven javascriptEvent driven javascript
Event driven javascriptFrancesca1980
 

Similaire à Components Are the New Thin Client (20)

FITC Web Unleashed 2017 - Introduction to the World of Testing for Front-End ...
FITC Web Unleashed 2017 - Introduction to the World of Testing for Front-End ...FITC Web Unleashed 2017 - Introduction to the World of Testing for Front-End ...
FITC Web Unleashed 2017 - Introduction to the World of Testing for Front-End ...
 
Introduction to ECMAScript 2015
Introduction to ECMAScript 2015Introduction to ECMAScript 2015
Introduction to ECMAScript 2015
 
Drools Introduction
Drools IntroductionDrools Introduction
Drools Introduction
 
React.js: Beyond the Browser
React.js: Beyond the BrowserReact.js: Beyond the Browser
React.js: Beyond the Browser
 
Ngrx slides
Ngrx slidesNgrx slides
Ngrx slides
 
Understanding redux
Understanding reduxUnderstanding redux
Understanding redux
 
Getting started with Elasticsearch and .NET
Getting started with Elasticsearch and .NETGetting started with Elasticsearch and .NET
Getting started with Elasticsearch and .NET
 
jRuby: The best of both worlds
jRuby: The best of both worldsjRuby: The best of both worlds
jRuby: The best of both worlds
 
Message-based communication patterns in distributed Akka applications
Message-based communication patterns in distributed Akka applicationsMessage-based communication patterns in distributed Akka applications
Message-based communication patterns in distributed Akka applications
 
Stop that!
Stop that!Stop that!
Stop that!
 
Fact, Fiction, and FP
Fact, Fiction, and FPFact, Fiction, and FP
Fact, Fiction, and FP
 
Javascript: the important bits
Javascript: the important bitsJavascript: the important bits
Javascript: the important bits
 
10 Billion a Day, 100 Milliseconds Per: Monitoring Real-Time Bidding at AdRoll
10 Billion a Day, 100 Milliseconds Per: Monitoring Real-Time Bidding at AdRoll10 Billion a Day, 100 Milliseconds Per: Monitoring Real-Time Bidding at AdRoll
10 Billion a Day, 100 Milliseconds Per: Monitoring Real-Time Bidding at AdRoll
 
Async Redux Actions With RxJS - React Rally 2016
Async Redux Actions With RxJS - React Rally 2016Async Redux Actions With RxJS - React Rally 2016
Async Redux Actions With RxJS - React Rally 2016
 
Clean code in JavaScript
Clean code in JavaScriptClean code in JavaScript
Clean code in JavaScript
 
Buenos Aires Drools Expert Presentation
Buenos Aires Drools Expert PresentationBuenos Aires Drools Expert Presentation
Buenos Aires Drools Expert Presentation
 
Concurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STM
Concurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STMConcurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STM
Concurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STM
 
Everyday's JS
Everyday's JSEveryday's JS
Everyday's JS
 
MongoDB World 2019: Life In Stitch-es
MongoDB World 2019: Life In Stitch-esMongoDB World 2019: Life In Stitch-es
MongoDB World 2019: Life In Stitch-es
 
Event driven javascript
Event driven javascriptEvent driven javascript
Event driven javascript
 

Plus de Lukas Ruebbelke

ng-conf 2017: Angular Mischief Maker Slides
ng-conf 2017: Angular Mischief Maker Slidesng-conf 2017: Angular Mischief Maker Slides
ng-conf 2017: Angular Mischief Maker SlidesLukas Ruebbelke
 
Embrace the Angular 2 Ethos in Angular 1.x
Embrace the Angular 2 Ethos in Angular 1.xEmbrace the Angular 2 Ethos in Angular 1.x
Embrace the Angular 2 Ethos in Angular 1.xLukas Ruebbelke
 
Go Beast Mode with Realtime Reactive Interfaces in Angular 2 and Firebase
Go Beast Mode with Realtime Reactive Interfaces in Angular 2 and FirebaseGo Beast Mode with Realtime Reactive Interfaces in Angular 2 and Firebase
Go Beast Mode with Realtime Reactive Interfaces in Angular 2 and FirebaseLukas Ruebbelke
 
Get that Corner Office with Angular 2 and Electron
Get that Corner Office with Angular 2 and ElectronGet that Corner Office with Angular 2 and Electron
Get that Corner Office with Angular 2 and ElectronLukas Ruebbelke
 
The REAL Angular Keynote
The REAL Angular KeynoteThe REAL Angular Keynote
The REAL Angular KeynoteLukas Ruebbelke
 
Impress Your Friends with EcmaScript 2015
Impress Your Friends with EcmaScript 2015Impress Your Friends with EcmaScript 2015
Impress Your Friends with EcmaScript 2015Lukas Ruebbelke
 
Turn Your Designers Into Death Stars with Angular
Turn Your Designers Into Death Stars with AngularTurn Your Designers Into Death Stars with Angular
Turn Your Designers Into Death Stars with AngularLukas Ruebbelke
 
Badges? We don't need no stinkin' badges!
Badges? We don't need no stinkin' badges!Badges? We don't need no stinkin' badges!
Badges? We don't need no stinkin' badges!Lukas Ruebbelke
 
Ionic Crash Course! Hack-a-ton SF
Ionic Crash Course! Hack-a-ton SFIonic Crash Course! Hack-a-ton SF
Ionic Crash Course! Hack-a-ton SFLukas Ruebbelke
 
ngEurope 2014: Become a Realtime Cage Dragon with Firebase and AngularJS
ngEurope 2014: Become a Realtime Cage Dragon with Firebase and AngularJSngEurope 2014: Become a Realtime Cage Dragon with Firebase and AngularJS
ngEurope 2014: Become a Realtime Cage Dragon with Firebase and AngularJSLukas Ruebbelke
 
AngularJS Directives - DSL for your HTML
AngularJS Directives - DSL for your HTMLAngularJS Directives - DSL for your HTML
AngularJS Directives - DSL for your HTMLLukas Ruebbelke
 

Plus de Lukas Ruebbelke (12)

ng-conf 2017: Angular Mischief Maker Slides
ng-conf 2017: Angular Mischief Maker Slidesng-conf 2017: Angular Mischief Maker Slides
ng-conf 2017: Angular Mischief Maker Slides
 
Embrace the Angular 2 Ethos in Angular 1.x
Embrace the Angular 2 Ethos in Angular 1.xEmbrace the Angular 2 Ethos in Angular 1.x
Embrace the Angular 2 Ethos in Angular 1.x
 
Go Beast Mode with Realtime Reactive Interfaces in Angular 2 and Firebase
Go Beast Mode with Realtime Reactive Interfaces in Angular 2 and FirebaseGo Beast Mode with Realtime Reactive Interfaces in Angular 2 and Firebase
Go Beast Mode with Realtime Reactive Interfaces in Angular 2 and Firebase
 
Get that Corner Office with Angular 2 and Electron
Get that Corner Office with Angular 2 and ElectronGet that Corner Office with Angular 2 and Electron
Get that Corner Office with Angular 2 and Electron
 
The REAL Angular Keynote
The REAL Angular KeynoteThe REAL Angular Keynote
The REAL Angular Keynote
 
Impress Your Friends with EcmaScript 2015
Impress Your Friends with EcmaScript 2015Impress Your Friends with EcmaScript 2015
Impress Your Friends with EcmaScript 2015
 
Turn Your Designers Into Death Stars with Angular
Turn Your Designers Into Death Stars with AngularTurn Your Designers Into Death Stars with Angular
Turn Your Designers Into Death Stars with Angular
 
Badges? We don't need no stinkin' badges!
Badges? We don't need no stinkin' badges!Badges? We don't need no stinkin' badges!
Badges? We don't need no stinkin' badges!
 
ngAnimate crash course
ngAnimate crash coursengAnimate crash course
ngAnimate crash course
 
Ionic Crash Course! Hack-a-ton SF
Ionic Crash Course! Hack-a-ton SFIonic Crash Course! Hack-a-ton SF
Ionic Crash Course! Hack-a-ton SF
 
ngEurope 2014: Become a Realtime Cage Dragon with Firebase and AngularJS
ngEurope 2014: Become a Realtime Cage Dragon with Firebase and AngularJSngEurope 2014: Become a Realtime Cage Dragon with Firebase and AngularJS
ngEurope 2014: Become a Realtime Cage Dragon with Firebase and AngularJS
 
AngularJS Directives - DSL for your HTML
AngularJS Directives - DSL for your HTMLAngularJS Directives - DSL for your HTML
AngularJS Directives - DSL for your HTML
 

Dernier

WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
tonesoftg
tonesoftgtonesoftg
tonesoftglanshi9
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...masabamasaba
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in sowetomasabamasaba
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareJim McKeeth
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...masabamasaba
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...Jittipong Loespradit
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...chiefasafspells
 

Dernier (20)

WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - Keynote
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security Program
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 

Components Are the New Thin Client

  • 1. components are the new THIN CLIENT!
  • 3. DOM jQuery “Application” $( "form" ).submit(function( event ) { if ( $( "input:first" ).val() === "correct" ) { $( "span" ).text( "Validated..." ).show(); return; } $( "span" ).text( "Not valid!" ).show().fadeOut( 1000 ); event.preventDefault(); });
  • 4. DOM First Generation AngularJS Application CONTROLLER
  • 5. DOM Second Generation AngularJS Application CONTROLLER SERVICE DOM CONTROLLER
  • 8. In classical physics, if you know everything about a system at some instant of time, and you also know the equations that govern how the system changes then you can predict the future. That's what we mean when we say that the classical laws of physics are deterministic. If we can say the same thing, but with the past and future reversed, the same equations tell you everything about the past. Such a system is called reversible. The Theoretical Minimum by Leonard Susskind
  • 9.
  • 10. In classical physics, if you know everything about a system at some instant of time, and you also know the equations that govern how the system changes then you can predict the future. That's what we mean when we say that the classical laws of physics are deterministic. If we can say the same thing, but with the past and future reversed, the same equations tell you everything about the past. Such a system is called reversible. The Theoretical Minimum by Leonard Susskind
  • 12. In classical physics, if you know everything about a system at some instant of time, and you also know the equations that govern how the system changes then you can predict the future. That's what we mean when we say that the classical laws of physics are deterministic. If we can say the same thing, but with the past and future reversed, the same equations tell you everything about the past. Such a system is called reversible. The Theoretical Minimum by Leonard Susskind
  • 14. In classical physics, if you know everything about a system at some instant of time, and you also know the equations that govern how the system changes then you can predict the future. That's what we mean when we say that the classical laws of physics are deterministic. If we can say the same thing, but with the past and future reversed, the same equations tell you everything about the past. Such a system is called reversible. The Theoretical Minimum by Leonard Susskind
  • 15. In classical physics, if you know everything about a system at some instant of time, and you also know the equations that govern how the system changes then you can predict the future. That's what we mean when we say that the classical laws of physics are deterministic. If we can say the same thing, but with the past and future reversed, the same equations tell you everything about the past. Such a system is called reversible. The Theoretical Minimum by Leonard Susskind
  • 16. User Input and Response
  • 17.
  • 18.
  • 21.
  • 22.
  • 23.
  • 24.
  • 27. actions = [ {type: '[Client] Select', payload: {id: '1', firstName: 'John', lastName: 'Doe', company: 'Acme, Inc'}}, {type: '[Client] Select', payload: {id: '2', firstName: 'Jane', lastName: 'Smith', company: 'Super, Inc'}}, {type: '[Client] Select', payload: {id: '1', firstName: 'John', lastName: 'Doe', company: 'Acme, Inc'}}, {type: '[Client] Select', payload: {id: '2', firstName: 'Jane', lastName: 'Smith', company: 'Super, Inc'}}, {type: '[Client] Select', payload: {id: '1', firstName: 'John', lastName: 'Doe', company: 'Acme, Inc'}}, {type: '[Client] Select', payload: {id: '2', firstName: 'Jane', lastName: 'Smith', company: 'Super, Inc'}}, ]; index = 0; step() { this.index = this.index < this.actions.length - 1 ? this.index + 1 : 0; this.store.dispatch(this.actions[this.index]); } Manual Dispatch
  • 31. actions = [ {type: '[Client] Select', payload: {id: '1', firstName: 'John', lastName: 'Doe', company: 'Acme, Inc'}}, {type: '[Client] Select', payload: {id: '2', firstName: 'Jane', lastName: 'Smith', company: 'Super, Inc'}}, {type: '[Client] Select', payload: {id: '1', firstName: 'John', lastName: 'Doe', company: 'Acme, Inc'}}, {type: '[Client] Select', payload: {id: '2', firstName: 'Jane', lastName: 'Smith', company: 'Super, Inc'}}, {type: '[Client] Select', payload: {id: '1', firstName: 'John', lastName: 'Doe', company: 'Acme, Inc'}}, {type: '[Client] Select', payload: {id: '2', firstName: 'Jane', lastName: 'Smith', company: 'Super, Inc'}}, ]; cycle() { const result = Observable .from(this.actions) .zip(Observable.interval(this.timerInterval), (a, b) => a) ; result.subscribe(action => this.store.dispatch(action)); } Manual Cycle
  • 35. fetchSingle() { this.actionsService .single() .subscribe(action => this.action = JSON.stringify(action, null , 't')); } dispatch(action) { this.store.dispatch(JSON.parse(action)); } Dynamic Dispatch
  • 39. fetchAll() { this.actionsService .all() .subscribe(actions => this.rawActions = JSON.stringify(actions, null , 't')); } dispatchCycle(rawActions) { const actions = JSON.parse(rawActions); const result = Observable .from(actions) .zip(Observable.interval(this.timerInterval), (a, b) => a) ; result.subscribe((action: any) => this.store.dispatch(action)); } Dynamic Dispatch
  • 42.
  • 43.
  • 44. constructor( private actionsService: ActionsService, private store: Store<reducers.AppState>, private afs: AngularFirestore ) { this.remoteActions = afs.collection('actions'); } ngOnInit() { this.remoteActions.valueChanges() .skip(1) .subscribe((actions: any) => { this.store.dispatch(actions[0]); }); } dispatchRemote(action) { this.remoteActions.add(JSON.parse(action)); } Remote Dispatch
  • 47. export function undoable(reducer: ActionReducer<any>): ActionReducer<any> { // Call the reducer with empty action to populate the initial state const initialState = { past: [], present: reducer(undefined, { type: ''}), future: [] }; // Return a reducer that handles undo and redo return function (state = initialState, action) { const { past, present, future } = state; switch (action.type) { case 'UNDO': // UNDO LOGIC case 'REDO': // REDO LOGIC default: // REGULAR LOGIC } }; } Meta Reducer
  • 49.
  • 52. Space and Time: Thin Component
  • 53. const CLIENT_LOAD = '[Client] Load'; const CLIENT_CREATE = '[Client] Create'; const CLIENT_UPDATE = '[Client] Update'; const CLIENT_DELETE = '[Client] Delete'; const CLIENT_SELECT = '[Client] Select'; const CLIENT_CLEAR = '[Client] Clear'; Actions
  • 54. const reducer = (state = initialState, {type, payload}) => { switch (type) { case CLIENT_LOAD: return state; case CLIENT_SELECT: return selectClient(state, payload); case CLIENT_CREATE: return createClient(state, payload); case CLIENT_UPDATE: return updateClient(state, payload); case CLIENT_DELETE: return deleteClient(state, payload); case CLIENT_CLEAR: return clearClient(state, payload); default: return state; } }; const store = new Store(reducer, initialState); Reducer
  • 55. export class ClientsComponent implements OnInit { clients$: Observable<Client[]>; currentClient$: Observable<Client>; constructor(private store: Store) { this.clients$ = this.store.select('clients'); this.currentClient$ = this.store.select('currentClient'); } ngOnInit() { this.store.dispatch(new ClientActions.LoadAction()); this.resetCurrentClient(); } resetCurrentClient() { const newClient: Client = { id: null, firstName: '', lastName: '', company: '' }; this.store.dispatch(new ClientActions.SelectAction(newClient)); } } ClientsComponent
  • 56. class Store { constructor(reducer) { this.reducer = reducer; this.state = reducer(undefined, { type: ''}); } getState() { return this.state.present; } dispatch(action) { this.state = this.reducer(this.state, action); } } Store
  • 57. io.on('connection', (socket) => { console.log('user connected'); io.emit('update', store.getState()); socket.on('dispatch', action => { store.dispatch(action); io.emit('update', store.getState()); }); socket.on('disconnect', function () { console.log('user disconnected'); }); }); http.listen(5000, () => { console.log('started on port 5000'); }); Socket.io
  • 58. const BASE_URL = 'http://localhost:5000'; export class SocketService { private socket; private subjects = {}; constructor() { this.socket = io(BASE_URL); this.socket.on('update', data => this.next(data)); } select(key) { this.subjects[key] = new BehaviorSubject(null); return this.subjects[key].asObservable(); } next(data) { for (const key in this.subjects) { if (this.subjects.hasOwnProperty(key)) { this.subjects[key].next(data[key]); } } } dispatch(action) { this.socket.emit('dispatch', action); } } SocketService