rx-hot-module

0.0.1 • Public • Published

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)

Dependencies (0)

    Dev Dependencies (3)

    Package Sidebar

    Install

    npm i rx-hot-module

    Weekly Downloads

    2

    Version

    0.0.1

    License

    ISC

    Last publish

    Collaborators

    • queerviolet