chore(): add callback arg to push

This commit is contained in:
Adam Bradley
2015-11-22 23:41:14 -06:00
parent 4e01ec09a2
commit ce192d62d6
2 changed files with 9 additions and 6 deletions

View File

@ -146,7 +146,7 @@ export class NavController extends Ion {
* @param {TODO} [opts={}] TODO * @param {TODO} [opts={}] TODO
* @returns {Promise} TODO * @returns {Promise} TODO
*/ */
push(componentType, params = {}, opts = {}) { push(componentType, params = {}, opts = {}, callback) {
if (!componentType) { if (!componentType) {
console.debug('invalid componentType to push'); console.debug('invalid componentType to push');
return Promise.reject(); return Promise.reject();
@ -164,7 +164,10 @@ export class NavController extends Ion {
this._lastPush = now; this._lastPush = now;
let resolve; let resolve;
let promise = new Promise(res => { resolve = res; }); let promise = null;
if (!callback) {
promise = new Promise(res => { callback = res; });
}
// do not animate if this is the first in the stack // do not animate if this is the first in the stack
if (!this._views.length && !opts.animateFirst) { if (!this._views.length && !opts.animateFirst) {
@ -202,7 +205,7 @@ export class NavController extends Ion {
} }
// start the transition // start the transition
this._transition(enteringView, leavingView, opts, resolve); this._transition(enteringView, leavingView, opts, callback);
return promise; return promise;
} }
@ -579,9 +582,9 @@ export class NavController extends Ion {
let navbarTemplateRef = viewCtrl.getNavbarTemplateRef(); let navbarTemplateRef = viewCtrl.getNavbarTemplateRef();
if (navbarContainerRef && navbarTemplateRef) { if (navbarContainerRef && navbarTemplateRef) {
console.time('loadPage ' + viewCtrl.componentType.name + ': createEmbeddedView'); console.time('loadPage ' + viewCtrl.componentType.name + ': create navbar');
let navbarView = navbarContainerRef.createEmbeddedView(navbarTemplateRef); let navbarView = navbarContainerRef.createEmbeddedView(navbarTemplateRef);
console.timeEnd('loadPage ' + viewCtrl.componentType.name + ': createEmbeddedView'); console.timeEnd('loadPage ' + viewCtrl.componentType.name + ': create navbar');
viewCtrl.addDestroy(() => { viewCtrl.addDestroy(() => {
let index = navbarContainerRef.indexOf(navbarView); let index = navbarContainerRef.indexOf(navbarView);

View File

@ -114,7 +114,7 @@ export class Tab extends NavController {
*/ */
load(opts, done) { load(opts, done) {
if (!this._loaded && this.root) { if (!this._loaded && this.root) {
this.push(this.root, null, opts).then(done); this.push(this.root, null, opts, done);
this._loaded = true; this._loaded = true;
} else { } else {