Updating Ember Models in Real-time with Sockets and Rx

Preview:

Citation preview

Updating Emberin Real-time

CLASS DISCUSSION UI

THE PROBLEM WITH CLASS DISCUSSION

• Everything should be real-time… eventually• Connect to a live events socket• Receive a mixed feed of all subscribed events• Manually register for chat channels• Forced disconnection every minute

Going Real-timeSERVICE CONSTRAINTS

First Attempt

• Staying connected to a unpredictable service• Updating with messages sent while disconnected• Maintaining state on live chat channels• Logic for all event types lived in one service• Slowly building an app-wide state machine

It Worked! But…KEY ISSUES

RxJSA complicated solution to a complicated problem!

RxJSA complicated solution to a complicated problem!

“[…] transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.”

🤔

It’s Not as Bad as You Think™

RxJS

• Observers• Events• Bindings• Array functions• Promises

RxJSIT’S MOSTLY STUFF YOU ALREADY KNOW

Staying Connected to a Unpredictable Service

STAYING CONNECTED TO A UNPREDICTABLE SERVICE

STAYING CONNECTED TO A UNPREDICTABLE SERVICE WITH RX

STAYING CONNECTED TO A UNPREDICTABLE SERVICE WITH RX

STAYING CONNECTED TO A UNPREDICTABLE SERVICE WITH RX

STAYING CONNECTED TO A UNPREDICTABLE SERVICE WITH RX

STAYING CONNECTED TO A UNPREDICTABLE SERVICE WITH RX

http://rxmarbles.com/#zip

STAYING CONNECTED TO A UNPREDICTABLE SERVICE WITH RX

STAYING CONNECTED TO A UNPREDICTABLE SERVICE WITH RX

ANYONE FEELING LIKE THIS?

Me too! Let’s keep going!

Actually Updating a Model

ACTUALLY UPDATING A MODEL

ACTUALLY UPDATING A MODEL

ACTUALLY UPDATING A MODEL

ACTUALLY UPDATING A MODEL

MAINTAINING STATE ON LIVE CHAT CHANNELS

Recommended