yoshuawuyts / barracks

:mountain_railway: action dispatcher for unidirectional data flows
MIT License
177 stars 22 forks source link

start: add hot-reload capability #50

Closed yoshuawuyts closed 7 years ago

yoshuawuyts commented 8 years ago

Should add HMR capabilities to barracks / choo - kinda experimental still tho butttt yeah putting it out there https://twitter.com/yoshuawuyts/status/751458983848845312

coveralls commented 8 years ago

Coverage Status

Coverage decreased (-3.3%) to 91.367% when pulling fb94517b8bac7df362a4f1bf8423b742efa56cff on hot-reload into 9f4b6f710ec7b1dfbe92a3f4a7ac489b5c593079 on master.

yoshuawuyts commented 8 years ago

Hmm, I don't like the API - if we're going to move towards an app.use() API to sugercoat plugins then this wouldn't work. We'd need the state value to sit next to the other hooks. API for HMR could then become:

const hmr = require('choo-hmr')
const choo = require('choo')

const app = choo()
app.use(hmr())

const tree = app.start()
document.body.appendChild(tree)
yoshuawuyts commented 8 years ago

Actually even better would be if there was an initialStateWrap() function - means we can trim bytes in production and move the logic to HMR :sparkles:

yoshuawuyts commented 8 years ago

hmr repo: https://github.com/yoshuawuyts/hot-app-replacement/tree/choo/

edit: probs wanna implement that over SSE or something hey

yoshuawuyts commented 7 years ago

Spring cleaning time 🕥 - PR has been inactive for a while, closing!