public override IPromise <RoutePopDisposition> willPop()
        {
            _ModalScopeState scope = this._scopeKey.currentState;

            D.assert(scope != null);

            var callbacks = new List <WillPopCallback>(this._willPopCallbacks);
            Promise <RoutePopDisposition> result = new Promise <RoutePopDisposition>();
            Action <int> fn = null;

            fn = (int index) => {
                if (index < callbacks.Count)
                {
                    callbacks[index]().Then((pop) => {
                        if (!pop)
                        {
                            result.Resolve(RoutePopDisposition.doNotPop);
                        }
                        else
                        {
                            fn(index + 1);
                        }
                    });
                }
                else
                {
                    base.willPop().Then((pop) => result.Resolve(pop));
                }
            };
            fn(0);
            return(result);
        }
Exemple #2
0
        public override Future <RoutePopDisposition> willPop()
        {
            //async
            _ModalScopeState scope = _scopeKey.currentState as _ModalScopeState;

            D.assert(scope != null);

            Future InvokePopCallbacks(int index)
            {
                if (index == _willPopCallbacks.Count)
                {
                    return(base.willPop());
                }
                var callback = _willPopCallbacks[index];

                return(callback.Invoke().then(v => {
                    if (!(bool)v)
                    {
                        return Future.value(RoutePopDisposition.doNotPop);
                    }

                    return InvokePopCallbacks(index + 1);
                }));
            }

            return(InvokePopCallbacks(0).to <RoutePopDisposition>());
        }