0.0.1 • Published 7 years ago
rx-hot-module v0.0.1
RxHotModule
When in the presence of Hot Module Replacement, export an Observable.
Example
// hot.js
import rxHot from './rxhot'
export default rxHot (module) ('hello world')
// entry.js
import hot from './hot'
if (typeof hot.subscribe === 'function') {
// Module is hot
hot
.map(phrase => phrase.length)
.subscribe(console.log)
} else {
console.log(hot.length)
}
If HMR is disabled, rxHot
returns the data object by default. To change
this behavior and always return an Observable, pass the {alwaysRx: true}
to rxHot
// hot.js
import rxHot from './rxhot'
export default rxHot (module, {alwaysRx: true}) ('hello world')
// entry.js
import hot from './hot'
// Module is always Observable
hot
.map(phrase => phrase.length)
.subscribe(console.log)
0.0.1
7 years ago