SlideShare une entreprise Scribd logo
1  sur  95
Télécharger pour lire hors ligne
Effects, coeffects &
subscriptions: a pit of
success for SPAs
Manuel Rivero
@trikitrok
About me
● I’m Manuel Rivero (@trikitrok).
● I’m a member of Codesai.
● I collaborate with BCN Software
Craftsmanship, Clojure
Developers BCN and
Aprendices (@deAprendices)
communities.
● My current client is
Green Power
Monitor where we
develop a SPA for
monitoring and
managing renewable
energy portfolios
using ClojureScript
and Om.
Thanks to:
● All the members of Clojure Developers BCN for all
the fun and evenings of sharing and learning.
● All the people in Codesai & Green Power Monitor
that gave me feedback to improve this talk.
● Francesc Guillén for introducing me to
ClojureScript, teaching me so much,
and letting me participate in his re-frame
+ React Native adventure.
Context
● Rewrite in ClojureScript a browser SPA written in
JavaScript that implements a visual method to
practice spelling.
● Create a mobile version, adding some improvements
and making it offline first.
● We wanted to share as much code as possible
between browser and mobile versions.
Stack
● ClojureScript.
● re-frame, a framework for writing SPAs in Clojurescript.
● Reagent a minimalistic interface between ClojureScript
and React.
● expo to build React Native apps that work across both
iOS and Android.
Some things we have learned
1. Effects & Coeffects
re-frame architecture (simplified version)
Unidirectional Data Flow Architecture
from re-frame wonderful docs
Imagine a re-frame app as a reduce
State Management
● At any point in time, app state results from
reducing over all events dispatched in the app
up until that time.
● The combining function for the reduce is the
set of registered event handlers.
Great if event handlers are pure functions
Pure Event Handlers
● Local reasoning
● Easier testing
● Events replay-ability
Side-effects are inevitable*
Side-causes Data a function requires but it does
not receive in its argument list
Side-effects What a function does to the world
What’s the problem with
effectful event handlers?
Effectful Event Handlers
● Action at a distance.
● Difficult to test.
● Events replay-ability is lost.
How do we usually try to fix this?
● Separation of concerns
● Test doubles
We regain isolation but, events
replay-ability is still lost...
Accidental Complexity!!!
DI in an event handler with a side effect
extended version
Testing event handler with a side effect
Testing event handler with a side effect
Testing event handler with a side effect
DI in an event handler with a side cause
extended version
Testing event handler with a side cause
Testing event handler with a side cause
Testing event handler with a side cause
Accidental Complexity!!!
Is there an easier way?
Effects and Coeffects
● Effects: describe your program’s
side-effects (what it does to the world)
● Coeffects: track your program’s
side-causes (what it requires from the world)
Declarative Effects pattern
● Event handlers are pure functions again
● They receive coeffects and return effects
● Injecting the values coeffects track and interpreting
effects to actually perform side-effects are done by
sth else (the language run-time, a framework, etc)
Declarative Effects pattern
Effects as Data, Richard Feldman
What do we get?
Pure event handlers again!
extended version
No test doubles!
Pure event handlers again!
extended version
Pure event handlers again!*
extended version
* using destructuring
No test doubles!
Pure Event Handlers
● Local reasoning
● Easier testing
● Events replay-ability
Pure functional Core
How are effects & coeffects handled?
Effect & Coeffects handlers
Effect & Coeffects handlers in re-frame
● Built-in effects handlers (:db, :dispatch, :dispatch-later, etc)
● Built-in coeffects handlers (:db)
● You can create your own custom effects and
coeffects handlers and register them into re-frame.
:timestamp is a custom coeffect
extended version
Pure Functional Core, Imperative Shell
re-frame architecture
Advantages over ports & adapters
● Less accidental complexity in business logic
● Remove business logic fragility to interface
changes in ports
● Still keeps pluggability (you can still use ports &
adapters in the imperative shell)
2. Subscriptions & Reactivity
re-frame architecture (simplified version)
re-frame subscriptions
● A novel and efficient de-duplicated
signal graph which runs query
functions on the app state
● These query functions extract data from
the app state and provide it to view
functions in the right format
re-frame subs
re-frame subs: Reactivity
Improve Performance
● By reducing renderings
● By de-duplicating computations
re-frame subs: Reactive signal graph
from re-frame wonderful docs
re-frame subs: Reactive signal graph
Simpler model & Dumb Views
● Avoid having to keep derived state in
the model (app state).
● Dumb down the views, that end up
being simple “data in, screen out”
functions
3. UI modeled as FSMs
Unidirectional Data Flow Architecture
from re-frame wonderful docs
re-frame architecture
Event Driven Data Flow
UI modeled as Finite State Machines
from a great Jeb Beich’s post in Cognitect’s blog
4. Design Constraints
and
Pits of success
Working against the architecture/design
Things could be much easier
A Pit of Success
“A well-designed system makes it
easy to do the right things and
annoying (but not impossible) to do
the wrong things.” Jeff Atwood
A Pit of Success
Functional architecture: The pits of success, Mark Seemann
Only pure functions for business logic
Isolated effectful code
UI modeled as FSMs
from a great Jeb Beich’s post in Cognitect’s blog
Subscriptions
● Reduce accidental complexity by
avoiding derived state
● Dumb views down
● Allow separated optimization of query
code using a reactive de-duplicated
signal graph
We were in a pit of success!
For redux users
Declarative effects:
● redux-saga or redux-loop
Subscriptions:
● reselect
5. Huge reuse
Views (browser)
Views (mobile)
Some effect handlers
6. What did ClojureScript
give us?
Elegant Weapons
from amazing xkcd comic
Sound functional language
● Immutable data structures
● Powerful standard library
● Reference types
● Lightweight but powerful polymorphism
Interactive Development
● Great development experience
○ REPL & Figwheel
● Different flow: RDD + TDD
○ Faster feedback cycles
Avoid JS tooling fatigue
ES5, ES6, ES7, JSX, Babel, TypeScript,
Webpack, …
7. No silver bullet
Hard things are still hard
re-frame puts you in a great starting point
However, you still have to work hard to get
good naming, model your domain,
discover useful abstractions and organize
your code
Beware of “shape” coupling
● Avoid that your code knows too
much about the app-state
representation.
● Especially important for tests.
Use builders.
Beware of long event cascades
● Some business logic might be
difficult to follow.
● Common problem in all
event-based systems:
● Paliate with tooling (re-frisk)
and packaging by feature.
Living on the bleeding edge
● expo: early days & quickly evolving =>
ClojureScript bindings continually
catching up.
● Still worth it though: avoids maintaining
different views for iOS and Android.
● It’ll get better as it stabilizes.
8. Conclusions
● Browser and mobile versions share most
of its code
● Effects, coeffects & subscriptions
○ Removes a lot of accidental complexity
○ A “pit of success”
● ClojureScript:
○ sound language
○ great interactive development flow
Thanks!!
Manuel Rivero @trikitrok
References & Links
● Effects & Coeffects
○ Coeffects: The next big programming challenge, Tomas Petricek
○ Side-effect, Wikipedia
○ What is functional programming?, Kris Jenkins
○ Avoiding Action at a Distance Is the Fast Track to Functional Programming, Ashley
Nelson-Hornstein
○ Effects as Data, Richard Felman
○ Unidirectional data flow architectures, Andre Staltz
○ Using coeffects in re-frame, Manuel Rivero
○ Using effects in re-frame, Manuel Rivero
○ Creating custom effects in re-frame, Manuel Rivero
○ An Introduction to Elm
○ Boundaries, Gary Bernhardt
References & Links
● UIs modeled as FSMs
○ Using State Machines to Simplify User Interface Development, Jeb Beich
○ Creating a User Interface with Re-frame and State Machines, Jeb Beich
● Pits of success
○ Functional architecture: The pits of success, Mark Seemann
○ Falling Into The Pit of Success, Jeff Atwood
○ A Good Language Conserves Programmer Energy, Eugene Wallingford
○ The deep synergy between testability and good design, Michael Feathers
● Simplifying React
○ 6 things Reacters do that Re-framers avoid, Eric Normand
○ A guide to the React Lifecycle Methods for Re-frame, Eric Normand
○ JSX vs Clojurescript: the showdown, Inge Solvoll
○ Comparing Reagent to React.js and Vue.js for dynamic tabular data, Dmitri Sotnikov
References & Links
● Interactivity
○ Developing ClojureScript With Figwheel, Bruce Hauman
○ Repl Driven Development, Stuart Sierra
● Other interesting links
○ Interview with Yassine Elouafi, creator of redux-saga
○ Elm architecture with React + Redux + Redux-loop, Egor Sapronov
○ Rethinking All Practices: Building Applications in Elm, Jamison Dance
○ Reduce side effects in React/Redux, Michal Zalecki
○ Managing side effects in Redux, Rico Sta. Cruz
○ Offline first
○ re-frame
○ Reagent
References & Links
○ React Native
○ re-natal
○ expo
○ Redux
○ reselect
○ redux-saga
○ redux-loop
○ Clojure Developers BCN Meetup
○ Aprendices Community on G+
○ Clojure Barcelona Community on G+
Note for myself: inevitable actually exists and means unavoidable... (see
the video of the talk when it comes out )
re-frame: how it works
discarded slide copied from
wonderful re-frame docs

Contenu connexe

Similaire à Effects, Coeffects & Subscriptions: a pit of success for SPAs

A Separation of Concerns: Clean Architecture on Android
A Separation of Concerns: Clean Architecture on AndroidA Separation of Concerns: Clean Architecture on Android
A Separation of Concerns: Clean Architecture on Android
Outware Mobile
 
Introduction to MVC in Flex and HydraMVC
Introduction to MVC in Flex and HydraMVCIntroduction to MVC in Flex and HydraMVC
Introduction to MVC in Flex and HydraMVC
cltru
 
Programming for non tech entrepreneurs
Programming for non tech entrepreneursProgramming for non tech entrepreneurs
Programming for non tech entrepreneurs
Rodrigo Gil
 

Similaire à Effects, Coeffects & Subscriptions: a pit of success for SPAs (20)

JavaScript for Enterprise Applications
JavaScript for Enterprise ApplicationsJavaScript for Enterprise Applications
JavaScript for Enterprise Applications
 
Keeping code clean
Keeping code cleanKeeping code clean
Keeping code clean
 
Asynchronous javascript
 Asynchronous javascript Asynchronous javascript
Asynchronous javascript
 
React for non techies
React for non techiesReact for non techies
React for non techies
 
A Separation of Concerns: Clean Architecture on Android
A Separation of Concerns: Clean Architecture on AndroidA Separation of Concerns: Clean Architecture on Android
A Separation of Concerns: Clean Architecture on Android
 
React for Non Techies
React for Non TechiesReact for Non Techies
React for Non Techies
 
React for non techies
React for non techiesReact for non techies
React for non techies
 
Dust.js
Dust.jsDust.js
Dust.js
 
Introduction to MVC in Flex and HydraMVC
Introduction to MVC in Flex and HydraMVCIntroduction to MVC in Flex and HydraMVC
Introduction to MVC in Flex and HydraMVC
 
Designing and coding for cloud-native applications using Python, Harjinder Mi...
Designing and coding for cloud-native applications using Python, Harjinder Mi...Designing and coding for cloud-native applications using Python, Harjinder Mi...
Designing and coding for cloud-native applications using Python, Harjinder Mi...
 
Best React js Training course in Bangalore
Best React js Training course in BangaloreBest React js Training course in Bangalore
Best React js Training course in Bangalore
 
Exploring the Real Power of Functional Programming
Exploring the Real Power of Functional ProgrammingExploring the Real Power of Functional Programming
Exploring the Real Power of Functional Programming
 
Evolving to Cloud-Native - Anand Rao
Evolving to Cloud-Native - Anand RaoEvolving to Cloud-Native - Anand Rao
Evolving to Cloud-Native - Anand Rao
 
Bots on guard of sdlc
Bots on guard of sdlcBots on guard of sdlc
Bots on guard of sdlc
 
Resume
ResumeResume
Resume
 
Why Concurrency is hard ?
Why Concurrency is hard ?Why Concurrency is hard ?
Why Concurrency is hard ?
 
Creating An App for 650 million customers v.2.pdf
Creating An App for 650 million customers v.2.pdfCreating An App for 650 million customers v.2.pdf
Creating An App for 650 million customers v.2.pdf
 
Concurrency - Why it's hard ?
Concurrency - Why it's hard ?Concurrency - Why it's hard ?
Concurrency - Why it's hard ?
 
Programming for non tech entrepreneurs
Programming for non tech entrepreneursProgramming for non tech entrepreneurs
Programming for non tech entrepreneurs
 
Globant Week Cali - Entendiendo el desarrollo Front-end del mundo moderno.
Globant Week Cali - Entendiendo el desarrollo Front-end del mundo moderno.Globant Week Cali - Entendiendo el desarrollo Front-end del mundo moderno.
Globant Week Cali - Entendiendo el desarrollo Front-end del mundo moderno.
 

Dernier

%+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
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 

Dernier (20)

WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
 
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...
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
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...
 
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...
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
%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
 
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
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
%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
 
%+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 Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
%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
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - Keynote
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 

Effects, Coeffects & Subscriptions: a pit of success for SPAs

  • 1. Effects, coeffects & subscriptions: a pit of success for SPAs Manuel Rivero @trikitrok
  • 2. About me ● I’m Manuel Rivero (@trikitrok). ● I’m a member of Codesai. ● I collaborate with BCN Software Craftsmanship, Clojure Developers BCN and Aprendices (@deAprendices) communities. ● My current client is Green Power Monitor where we develop a SPA for monitoring and managing renewable energy portfolios using ClojureScript and Om.
  • 3. Thanks to: ● All the members of Clojure Developers BCN for all the fun and evenings of sharing and learning. ● All the people in Codesai & Green Power Monitor that gave me feedback to improve this talk. ● Francesc Guillén for introducing me to ClojureScript, teaching me so much, and letting me participate in his re-frame + React Native adventure.
  • 4. Context ● Rewrite in ClojureScript a browser SPA written in JavaScript that implements a visual method to practice spelling. ● Create a mobile version, adding some improvements and making it offline first. ● We wanted to share as much code as possible between browser and mobile versions.
  • 5. Stack ● ClojureScript. ● re-frame, a framework for writing SPAs in Clojurescript. ● Reagent a minimalistic interface between ClojureScript and React. ● expo to build React Native apps that work across both iOS and Android.
  • 6. Some things we have learned
  • 7. 1. Effects & Coeffects
  • 9. Unidirectional Data Flow Architecture from re-frame wonderful docs
  • 10. Imagine a re-frame app as a reduce
  • 11. State Management ● At any point in time, app state results from reducing over all events dispatched in the app up until that time. ● The combining function for the reduce is the set of registered event handlers.
  • 12. Great if event handlers are pure functions
  • 13. Pure Event Handlers ● Local reasoning ● Easier testing ● Events replay-ability
  • 15. Side-causes Data a function requires but it does not receive in its argument list
  • 16. Side-effects What a function does to the world
  • 17. What’s the problem with effectful event handlers?
  • 18. Effectful Event Handlers ● Action at a distance. ● Difficult to test. ● Events replay-ability is lost.
  • 19. How do we usually try to fix this? ● Separation of concerns ● Test doubles We regain isolation but, events replay-ability is still lost...
  • 21. DI in an event handler with a side effect extended version
  • 22. Testing event handler with a side effect
  • 23. Testing event handler with a side effect
  • 24. Testing event handler with a side effect
  • 25. DI in an event handler with a side cause extended version
  • 26. Testing event handler with a side cause
  • 27. Testing event handler with a side cause
  • 28. Testing event handler with a side cause
  • 30. Is there an easier way?
  • 31. Effects and Coeffects ● Effects: describe your program’s side-effects (what it does to the world) ● Coeffects: track your program’s side-causes (what it requires from the world)
  • 32. Declarative Effects pattern ● Event handlers are pure functions again ● They receive coeffects and return effects ● Injecting the values coeffects track and interpreting effects to actually perform side-effects are done by sth else (the language run-time, a framework, etc)
  • 33. Declarative Effects pattern Effects as Data, Richard Feldman
  • 34. What do we get?
  • 35. Pure event handlers again! extended version
  • 37. Pure event handlers again! extended version
  • 38. Pure event handlers again!* extended version * using destructuring
  • 40. Pure Event Handlers ● Local reasoning ● Easier testing ● Events replay-ability
  • 42. How are effects & coeffects handled?
  • 43. Effect & Coeffects handlers
  • 44. Effect & Coeffects handlers in re-frame ● Built-in effects handlers (:db, :dispatch, :dispatch-later, etc) ● Built-in coeffects handlers (:db) ● You can create your own custom effects and coeffects handlers and register them into re-frame.
  • 45. :timestamp is a custom coeffect extended version
  • 46. Pure Functional Core, Imperative Shell
  • 48. Advantages over ports & adapters ● Less accidental complexity in business logic ● Remove business logic fragility to interface changes in ports ● Still keeps pluggability (you can still use ports & adapters in the imperative shell)
  • 49. 2. Subscriptions & Reactivity
  • 51. re-frame subscriptions ● A novel and efficient de-duplicated signal graph which runs query functions on the app state ● These query functions extract data from the app state and provide it to view functions in the right format
  • 54. Improve Performance ● By reducing renderings ● By de-duplicating computations
  • 55. re-frame subs: Reactive signal graph from re-frame wonderful docs
  • 56. re-frame subs: Reactive signal graph
  • 57. Simpler model & Dumb Views ● Avoid having to keep derived state in the model (app state). ● Dumb down the views, that end up being simple “data in, screen out” functions
  • 58. 3. UI modeled as FSMs
  • 59. Unidirectional Data Flow Architecture from re-frame wonderful docs
  • 62. UI modeled as Finite State Machines from a great Jeb Beich’s post in Cognitect’s blog
  • 64. Working against the architecture/design
  • 65. Things could be much easier
  • 66. A Pit of Success “A well-designed system makes it easy to do the right things and annoying (but not impossible) to do the wrong things.” Jeff Atwood
  • 67. A Pit of Success Functional architecture: The pits of success, Mark Seemann
  • 68. Only pure functions for business logic
  • 70. UI modeled as FSMs from a great Jeb Beich’s post in Cognitect’s blog
  • 71. Subscriptions ● Reduce accidental complexity by avoiding derived state ● Dumb views down ● Allow separated optimization of query code using a reactive de-duplicated signal graph
  • 72. We were in a pit of success!
  • 73. For redux users Declarative effects: ● redux-saga or redux-loop Subscriptions: ● reselect
  • 78. 6. What did ClojureScript give us?
  • 80. Sound functional language ● Immutable data structures ● Powerful standard library ● Reference types ● Lightweight but powerful polymorphism
  • 81. Interactive Development ● Great development experience ○ REPL & Figwheel ● Different flow: RDD + TDD ○ Faster feedback cycles
  • 82. Avoid JS tooling fatigue ES5, ES6, ES7, JSX, Babel, TypeScript, Webpack, …
  • 83. 7. No silver bullet
  • 84. Hard things are still hard re-frame puts you in a great starting point However, you still have to work hard to get good naming, model your domain, discover useful abstractions and organize your code
  • 85. Beware of “shape” coupling ● Avoid that your code knows too much about the app-state representation. ● Especially important for tests. Use builders.
  • 86. Beware of long event cascades ● Some business logic might be difficult to follow. ● Common problem in all event-based systems: ● Paliate with tooling (re-frisk) and packaging by feature.
  • 87. Living on the bleeding edge ● expo: early days & quickly evolving => ClojureScript bindings continually catching up. ● Still worth it though: avoids maintaining different views for iOS and Android. ● It’ll get better as it stabilizes.
  • 89. ● Browser and mobile versions share most of its code ● Effects, coeffects & subscriptions ○ Removes a lot of accidental complexity ○ A “pit of success” ● ClojureScript: ○ sound language ○ great interactive development flow
  • 91. References & Links ● Effects & Coeffects ○ Coeffects: The next big programming challenge, Tomas Petricek ○ Side-effect, Wikipedia ○ What is functional programming?, Kris Jenkins ○ Avoiding Action at a Distance Is the Fast Track to Functional Programming, Ashley Nelson-Hornstein ○ Effects as Data, Richard Felman ○ Unidirectional data flow architectures, Andre Staltz ○ Using coeffects in re-frame, Manuel Rivero ○ Using effects in re-frame, Manuel Rivero ○ Creating custom effects in re-frame, Manuel Rivero ○ An Introduction to Elm ○ Boundaries, Gary Bernhardt
  • 92. References & Links ● UIs modeled as FSMs ○ Using State Machines to Simplify User Interface Development, Jeb Beich ○ Creating a User Interface with Re-frame and State Machines, Jeb Beich ● Pits of success ○ Functional architecture: The pits of success, Mark Seemann ○ Falling Into The Pit of Success, Jeff Atwood ○ A Good Language Conserves Programmer Energy, Eugene Wallingford ○ The deep synergy between testability and good design, Michael Feathers ● Simplifying React ○ 6 things Reacters do that Re-framers avoid, Eric Normand ○ A guide to the React Lifecycle Methods for Re-frame, Eric Normand ○ JSX vs Clojurescript: the showdown, Inge Solvoll ○ Comparing Reagent to React.js and Vue.js for dynamic tabular data, Dmitri Sotnikov
  • 93. References & Links ● Interactivity ○ Developing ClojureScript With Figwheel, Bruce Hauman ○ Repl Driven Development, Stuart Sierra ● Other interesting links ○ Interview with Yassine Elouafi, creator of redux-saga ○ Elm architecture with React + Redux + Redux-loop, Egor Sapronov ○ Rethinking All Practices: Building Applications in Elm, Jamison Dance ○ Reduce side effects in React/Redux, Michal Zalecki ○ Managing side effects in Redux, Rico Sta. Cruz ○ Offline first ○ re-frame ○ Reagent
  • 94. References & Links ○ React Native ○ re-natal ○ expo ○ Redux ○ reselect ○ redux-saga ○ redux-loop ○ Clojure Developers BCN Meetup ○ Aprendices Community on G+ ○ Clojure Barcelona Community on G+ Note for myself: inevitable actually exists and means unavoidable... (see the video of the talk when it comes out )
  • 95. re-frame: how it works discarded slide copied from wonderful re-frame docs