jamielob / reloader

More control over hot code push reloading for your production apps. Designed to replace mdg:reload-on-resume and provide a more production-ready approach.
28 stars 22 forks source link

Mostly only cordova #7

Closed lorensr closed 8 years ago

lorensr commented 8 years ago

My refactor broke web reloading :) We can use this method of making the api callable from outside cordova:

https://github.com/meteor/mobile-packages/blob/master/packages/mdg:reload-on-resume/browser.js https://github.com/meteor/mobile-packages/blob/master/packages/mdg:reload-on-resume/package.js

lorensr commented 8 years ago

would fix this: https://github.com/jamielob/reloader/blob/master/reloader-tests.js#L1-L3

lorensr commented 8 years ago

Actually, that's probably due to us not returning an array from _onMigrate. Compare to reload-on-resume

image

gbhatnag commented 8 years ago

Looking at the original definition of Reload._onMigrate (at ~/.meteor/packages/reload/1.1.4/web.browser/packages/reload.js), there are docs that preface the method and the role of the retry function. Here's the full text --

// Packages that support migration should register themselves by calling                   // 104
// this function. When it's time to migrate, callback will be called                       // 105
// with one argument, the "retry function," and an optional 'option'                       // 106
// argument (containing a key 'immediateMigration'). If the package                        // 107
// is ready to migrate, it should return [true, data], where data is                       // 108
// its migration data, an arbitrary JSON value (or [true] if it has                        // 109
// no migration data this time). If the package needs more time                            // 110
// before it is ready to migrate, it should return false. Then, once                       // 111
// it is ready to migrating again, it should call the retry                                // 112
// function. The retry function will return immediately, but will                          // 113
// schedule the migration to be retried, meaning that every package                        // 114
// will be polled once again for its migration data. If they are all                       // 115
// ready this time, then the migration will happen. name must be set if there              // 116
// is migration data. If 'immediateMigration' is set in the options                        // 117
// argument, then it doesn't matter whether the package is ready to                        // 118
// migrate or not; the reload will happen immediately without waiting                      // 119
// (used for OAuth redirect login).                                                        // 120
//                                                                                         // 121
Reload._onMigrate = function (name, callback) {                                            // 122
  if (!callback) {                                                                         // 123
    // name not provided, so first arg is callback.                                        // 124
    callback = name;                                                                       // 125
    name = undefined;                                                                      // 126
  }                                                                                        // 127
  providers.push({name: name, callback: callback});                                        // 128
};                                                                                         // 129

(the full code is available here: https://github.com/meteor/meteor/blob/devel/packages/reload/reload.js)

Is there some reason we're not using the retry function?

lorensr commented 8 years ago

Probably just we didn't know about it :) Looks like it's something we should use

lorensr commented 8 years ago

Thanks 😄