SlideShare a Scribd company logo
1. Angular
2. MobX
3. Happiness
Adam Klein
Adam Klein
-Frontend developer & consultant
-Open source (ng2-tree, ng2-mobx)
-Co-organizer of AngularUP
-Fun fact: I used to have a jewfro
CTO @ 500Tech
Angular. MobX. Happiness
mmmm…. cake….
Regular
checkbox
Selected Items
Master
Checkbox
Master
Checkbox
Filtered Items
add a
framework
change filter
Imperative
Declarative
getFilteredItems() {

const regexp = new RegExp(this.filter, 'i');



return this.items
.filter((item) => regexp.test(item.name));

}
Declarative
Declarative
<div *ngFor="let item of getFilteredItems()">

{{ item.title }}

</div>

Declarative
<div *ngFor="let item of getFilteredItems()">

{{ item.title }}

</div>

Angular. MobX. Happiness
Angular. MobX. Happiness
Being declarative
&
Staying performant?
PRESENTATION
TITLE
Presenter Name
Small Subtitle
[DELETE THIS]: Presentation caption should be ALL CAPS, small subtitle should be All Capitalized
MobX
yes we can
Michel Weststrate from Mendix
Was written for React
Completely framework agnostic
Automagically react to changes
Works with plain objects
MobX
Taking the state out of
components
Items Filter
Checkbox
List
Filter
Add New
Selected
Items
Remove
Item
Input
Selected
Item
App
State
Components
State
Minimal State
(@observable)
List of
Frameworks
Selected
Items
Filter
Master
Checkbox
Filtered
Items
Derived State
(@computed)


@Injectable()
class State {

filter = '';

items = [];

}
Observable


@Injectable()
class State {

filter = '';

items = [];

}
Observable
import { observable } from 'mobx';

@Injectable()
class State {

@observable filter = '';

@observable items = [];

}
Observable
…
getFilteredItems() {

const regexp = new RegExp(this.filter, 'i');



return this.items
.filter((item) => regexp.test(item.name));

}
…
Computed
…
@computed get filteredItems() {

const regexp = new RegExp(this.filter, 'i');



return this.items
.filter((item) => regexp.test(item.name));

}
…
Computed
…
@computed get filteredItems() {

const regexp = new RegExp(this.filter, 'i');



return this.items
.filter((item) => regexp.test(item.name));

}
…
Computed
…
setFilter(value) {

this.filter = value;

}

…
Action
…
setFilter(value) {

this.filter = value;

}

…
Action
…
@action setFilter(value) {

this.filter = value;

}

…
Action
Angular. MobX. Happiness
List of
Frameworks
Selected
Items
Filter
Master
Checkbox
Filtered
Items
Selected Frameworks
Component
Frameworks Filter
Component
UI Components Obesrve?
State
Angular. MobX. Happiness
ng2-mobxgithub.com/500tech/
• 64 lines of code
• Automatically observes state from the components
• Deregisters observers onDestroy
With MobX
With MobX
export class SelectedItemsComponent {

constructor(private state:State) {}

}

<div>

{{ state.filteredItems }}

</div>
ng2-mobx
export class SelectedItemsComponent {

constructor(private state:State) {}

}

<div>

{{ state.filteredItems }}
</div>
ng2-mobx
export class SelectedItemsComponent {

constructor(private state:State) {}

}

<div>

{{ state.filteredItems }}
</div>
ng2-mobx
export class SelectedItemsComponent {

constructor(private state:State) {}

}

<div *mobxAutorun>

{{ state.filteredItems }}

</div>
ng2-mobx
@observable
List of
Frameworks
Selected
Items
Filter
Master
Checkbox
Filtered
Items
@computed
Selected Frameworks
Component
Frameworks Filter
Component
UI Componentsng2-mobx
Angular. MobX. Happiness
Angular. MobX. Happiness
Angular. MobX. Happiness
ChangeDetectionStrategy.OnPush
Angular. MobX. Happiness
Angular. MobX. Happiness
Angular. MobX. Happiness
Angular. MobX. Happiness
Angular. MobX. Happiness
MobX Redux
Plain objects
Immutable data
actions, middleware, dispatcher,
reducers, selectors
Automatic Explicit
Computed values Use reselect
What’s next?
ng-mobx for Angular1
@adamklein500
www.slideshare.net/500tech
Our slides:
Adam Klein
adam@500tech.com
https://github.com/500tech/angular1-mobx-demo
https://github.com/500tech/angular2-mobx-demo
Thank You
MAKE
ANGULAR
GREAT
AGAIN

More Related Content

PPTX
CocoaHeads Moscow. Азиз Латыпов, VIPole. «Запросы в CoreData с агрегатными фу...
PDF
Data driven testing using Integrant & Spec
PDF
Functional Core, Reactive Shell
PPTX
What's new for developers in Dynamics 365 v9: Client API enhancement
PDF
How to write easy-to-test JavaScript
PDF
The Ring programming language version 1.9 book - Part 77 of 210
PPTX
WordPress Hooks Action & Filters
PDF
Effective Java with Groovy - How Language Influences Adoption of Good Practices
CocoaHeads Moscow. Азиз Латыпов, VIPole. «Запросы в CoreData с агрегатными фу...
Data driven testing using Integrant & Spec
Functional Core, Reactive Shell
What's new for developers in Dynamics 365 v9: Client API enhancement
How to write easy-to-test JavaScript
The Ring programming language version 1.9 book - Part 77 of 210
WordPress Hooks Action & Filters
Effective Java with Groovy - How Language Influences Adoption of Good Practices

What's hot (20)

PDF
Clojure functions midje
PDF
Refactoring
TXT
Array operators
DOCX
VPN Access Runbook
PDF
APPlause - DemoCamp Munich
PDF
React for Beginners
PPT
Spring + JPA + DAO Step by Step
PDF
ES6 Simplified
PDF
What Have The Properties Ever Done For Us
PDF
Oleksandr Tolstykh
PDF
The Steel industry, Elixir, PostgreSQL & file_fdw
PDF
Incremental Type Safety in React Apollo
PPTX
Firebase ng2 zurich
PDF
Graphql, REST and Apollo
PDF
Crafting [Better] API Clients
PDF
Nativescript angular
PDF
JavaScript Functions
PDF
Ruby Programming Language
PPTX
Computer Science Homework Help
PDF
Open XKE - Big Data, Big Mess par Bertrand Dechoux
Clojure functions midje
Refactoring
Array operators
VPN Access Runbook
APPlause - DemoCamp Munich
React for Beginners
Spring + JPA + DAO Step by Step
ES6 Simplified
What Have The Properties Ever Done For Us
Oleksandr Tolstykh
The Steel industry, Elixir, PostgreSQL & file_fdw
Incremental Type Safety in React Apollo
Firebase ng2 zurich
Graphql, REST and Apollo
Crafting [Better] API Clients
Nativescript angular
JavaScript Functions
Ruby Programming Language
Computer Science Homework Help
Open XKE - Big Data, Big Mess par Bertrand Dechoux
Ad

Similar to Angular. MobX. Happiness (20)

KEY
Introducing CakeEntity
PDF
Practical Google App Engine Applications In Py
PDF
[@IndeedEng] Building Indeed Resume Search
PDF
The Future of the Web
PPTX
Building High Performance Web Applications and Sites
PDF
Pyconie 2012
PDF
Rewriting the Drupal Theme layer
PDF
The Ring programming language version 1.9 book - Part 90 of 210
PPT
DESIGNING A PERSISTENCE FRAMEWORK WITH PATTERNS.ppt
PDF
PDF
The Ring programming language version 1.3 book - Part 7 of 88
PDF
New Features in DITA 1.2
PDF
Javascript Design Patterns
PDF
How to Mess Up Your Angular UI Components
PDF
The Ring programming language version 1.5.1 book - Part 12 of 180
PPT
PPTX
the next web now
PPTX
Oojs 1.1
PDF
Mobx - performance and sanity
PDF
PostgreSQL Open SV 2018
Introducing CakeEntity
Practical Google App Engine Applications In Py
[@IndeedEng] Building Indeed Resume Search
The Future of the Web
Building High Performance Web Applications and Sites
Pyconie 2012
Rewriting the Drupal Theme layer
The Ring programming language version 1.9 book - Part 90 of 210
DESIGNING A PERSISTENCE FRAMEWORK WITH PATTERNS.ppt
The Ring programming language version 1.3 book - Part 7 of 88
New Features in DITA 1.2
Javascript Design Patterns
How to Mess Up Your Angular UI Components
The Ring programming language version 1.5.1 book - Part 12 of 180
the next web now
Oojs 1.1
Mobx - performance and sanity
PostgreSQL Open SV 2018
Ad

More from 500Tech (20)

PDF
State managment in a world of hooks
PDF
State managment in a world of hooks
PDF
React Under the Hook - DevDays Europe 2019
PDF
React Back to the Future
PDF
Hooks - why should you care today?
PDF
Migrating from angular to react
PDF
How to write bad code in redux (ReactNext 2018)
PDF
Opinionated Approach to Redux
PDF
Mobx Internals
PDF
Mobx - Performance and Sanity
PDF
Mobx Performance and Sanity
PDF
Tales of an open source library
PDF
Angular2 a modern web platform
PDF
Render to DOM
PDF
Managing state in Angular 1.x with Redux
PDF
Higher-Order Components — Ilya Gelman
PDF
React vs angular
PDF
D3 svg & angular
PDF
ReactJS vs AngularJS - Head to Head comparison
PDF
Understanding Redux — Ilya Gelman
State managment in a world of hooks
State managment in a world of hooks
React Under the Hook - DevDays Europe 2019
React Back to the Future
Hooks - why should you care today?
Migrating from angular to react
How to write bad code in redux (ReactNext 2018)
Opinionated Approach to Redux
Mobx Internals
Mobx - Performance and Sanity
Mobx Performance and Sanity
Tales of an open source library
Angular2 a modern web platform
Render to DOM
Managing state in Angular 1.x with Redux
Higher-Order Components — Ilya Gelman
React vs angular
D3 svg & angular
ReactJS vs AngularJS - Head to Head comparison
Understanding Redux — Ilya Gelman

Recently uploaded (20)

PDF
KodekX | Application Modernization Development
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Machine learning based COVID-19 study performance prediction
PDF
cuic standard and advanced reporting.pdf
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Empathic Computing: Creating Shared Understanding
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
Big Data Technologies - Introduction.pptx
PPTX
Cloud computing and distributed systems.
KodekX | Application Modernization Development
MYSQL Presentation for SQL database connectivity
Chapter 3 Spatial Domain Image Processing.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
Reach Out and Touch Someone: Haptics and Empathic Computing
The AUB Centre for AI in Media Proposal.docx
Machine learning based COVID-19 study performance prediction
cuic standard and advanced reporting.pdf
Building Integrated photovoltaic BIPV_UPV.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
Empathic Computing: Creating Shared Understanding
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
NewMind AI Weekly Chronicles - August'25 Week I
Understanding_Digital_Forensics_Presentation.pptx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Encapsulation_ Review paper, used for researhc scholars
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Big Data Technologies - Introduction.pptx
Cloud computing and distributed systems.

Angular. MobX. Happiness