際際滷

際際滷Share a Scribd company logo
ngRepeat
vs
ngReact
ngRepeat vs ngReact
ngRepeat vs ngReact
ngRepeat vs ngReact
Martin Fowlers Design Stamina Hypothesis
WebSocket Load
balancing
Permission and
security model
(Admin, Mods, ...)
Frontend Server Backend Server
UI
Chat System
Frontend
Server
NodeJs
data storage
Redis
Cluster
hitbox
REST-API
PHP
Nginx
Backend
Server
NodeJs
Auto scaling
Auto scaling
Long Polling Fallback
Fallback
Server
NodeJs
ngRepeat
ngRepeat vs ngReact
ngRepeat vs ngReact
ngRepeat vs ngReact
Demo
ngReact
Chatmessage Service
Websocket
Controller
Angular Template
React Component
ngRepeat vs ngReact
ngRepeat vs ngReact
ngRepeat vs ngReact
Demo
Thank you!
jg@hitbox.tv
max@hitbox.tv
We are hiring!
jobs.hitbox.tv

More Related Content

ngRepeat vs ngReact

Editor's Notes

  1. What i want to talk about
  2. What is hitbox? A streaming service f端r gamer
  3. This is the startpage
  4. And this is a watchpage. On eintegrap part of it is the schat on the right, where poeple communicate with the broadcaster
  5. -start with lean -> with just as much effort,as required and when the idea is proved, restructure and make it more maintainable -the hitbox application were made in lean, so we have legacy code -but the idea has proved, and now we are stabilizing the application/making it better -first thing was the chat
  6. This is how the chat is build
  7. What i want to talk about
  8. -fun part -> message bodies (HTML) were generated as string properties of js objects, which is bad practice, but we didnt change this, because we could reuse the exact same message body with react like before, this allowed us to change to ngReact fast, without too much effort, but if you start from scratch, dont do this
  9. we had to use $scope.$apply on each message, so if we had 80messages/sec that triggered 80diggest loops/sec. If you do the math, basically you have 16ms for everything to get 60fps on the browser, for the simplicity, let's just say we have 16ms for the digest loops (in reality 16ms is for everything, including all js, render, etc..), if you divide 16/80 that means, you have 0.2ms (200袖s) for the digest loop, and we know, in a complex application, a digest loop below 1ms is rare so
  10. so
  11. What i want to talk about
  12. What i want to talk about
  13. - we have a separate service for messages, called chatMessages - the react component have a state array which will be used in the template, and the react component subscribes with a callback function(setItems) for new messages in the chatMessages service - a websocket message can push new message into an array in the chatMessages service
  14. so
  15. while we push to the array, we limit the length of the messages array to 300 [MAX this is only for you: what we do is we check if the length is above 300, and if it is, we limit the messages array to 150, however we could just limit it to 300, and forget this 150 thing. I don't remember why I implemented like this, but I think we could just let 300 messages to be in the DOM all the time]
  16. What i want to talk about
  17. Just one mor think:
  18. We are hiring!