20
Immutable Performance Randy Lien @React.JS TW 第五次聚

Immutable, performance and components communication

Embed Size (px)

Citation preview

Page 1: Immutable, performance and components communication

Immutable Performance

Randy [email protected] TW 第五次⼩小聚

Page 2: Immutable, performance and components communication

About Me

• @randylien

• Front end developer

Page 3: Immutable, performance and components communication

Agenda

• Immutable

• Performance

• Components Communication

• Conclusion

Page 4: Immutable, performance and components communication

Functional Programming

Page 5: Immutable, performance and components communication
Page 6: Immutable, performance and components communication

Why Immutable?

• Immutable data has no side effect!

• Shared mutable state is the root of all evil - Pete Hunt

• You will not get hurt by yourself or someone

Page 7: Immutable, performance and components communication
Page 8: Immutable, performance and components communication

Why Immutable? (cont.)

• Immutable.js is fast enough and memory optimisation

• Why Om is faster ? Data or Value is immutable in Clojure/ClojureScript

• Immutable + PureRenderMixin

Page 9: Immutable, performance and components communication

Simple Made Easy

Page 10: Immutable, performance and components communication

Performance

Page 11: Immutable, performance and components communication

Performance

• Pure Component (prop & state)

• shouldComponentUpdate

• Don’t update when its the same

Page 12: Immutable, performance and components communication

Performance (cont.)• Container Component Pattern

• Container Component as Data Layer

• Data fetching

• Component is all about its behaviour

• Testing Container or Gallery Container

Page 13: Immutable, performance and components communication

Components Communication

Page 14: Immutable, performance and components communication

How to Communicate• Parent - Children

• Use Callbacks

• No relationship

• Global event hub

• Flux

• Codecademy

• Adapter, broadcast

• Channel (CSP)

• Cursor (react-cursor)

Page 15: Immutable, performance and components communication
Page 16: Immutable, performance and components communication

Conclusion

Page 17: Immutable, performance and components communication

Conclusion• Embracing Immutable data for the future (JavaScript)

development

• Componentize your User Interface

• Loose coupling your component

• Container Component

• General Component

• You can pick the suitable solution for your needs

Page 18: Immutable, performance and components communication
Page 19: Immutable, performance and components communication

Conclusion(cont.)

• Watch Simple made easy

• Try Clojure/ClojureScript

Page 20: Immutable, performance and components communication

FAQ