alexisvincent / systemjs-hot-reloader

reloads your modules as needed so that you can have satisfyingly fast feedback loop when developing your app
MIT License
228 stars 36 forks source link

Reload Method? #134

Open jcmoore0 opened 7 years ago

jcmoore0 commented 7 years ago

Hi Alexis - I am trying to use the new version on an Angular2 project. I am not sure how to use it. The new version looks to be using a different reload mechanism than previously (below).
Do you have any sample?
Thanks for your incredible work here! Best regards, John

let HotReloader: any = <any>window[<any>'hr'];
HotReloader && HotReloader.on('change', (fileName: string) => {
    if (fileName.indexOf('html') !== -1) {
        var newBody = document.createElement('body')
        newBody.appendChild(document.createElement('sparq-app'))
        document.body = newBody;
        platformBrowserDynamic().bootstrapModule(AppModule);
    }
});
alexisvincent commented 7 years ago

Hi @jcmoore0.

Yeah, the eventing model has been stripped away (I'm planning on replacing it with an Rx Observable). I'm guessing here you're wanting to to save yourself a page reload?

jcmoore0 commented 7 years ago

Thanks for the quick reply. Your observable plan sounds terrific.

You got it. I am wanting to save some reload time :)

Hot reload goals: 1) html on html change detected (html is outside js before production bundling)
2) module/component reload on js file change detected 3) module recompile reload on ts file change detected

I was doing #1 with the previous version.
I am looking for a sample to make at #1 work with the new version and eventually do 2 and 3. Best regards, John

alexisvincent commented 7 years ago

If I understand you correctly, then you should have 2 and 3 out of the box. 1 is trickier at the moment since theres no eventing api yet. Are you just saving yourself the full page refresh? Because that shouldn't be happening that often.

If you can give me an example repository I might be able to help you better.