コード例 #1
0
        protected override void PostConstruct()
        {
            base.PostConstruct();

            var disposed = Disposed.Where(identity);

            OnItemsChange
            .Do(items => Items = items)
            .TakeUntil(disposed)
            .Subscribe(HandleItemsChange, this);

            OnNavigate
            .Do(_ => UpLabel.Iter(l => l.Active = this.CanGoUp()))
            .Select(i => i.Bind(v => v.GetPath()).Reverse())
            .Select(p => string.Join(" > ", p.Map(v => v.DisplayName)))
            .TakeUntil(disposed)
            .Subscribe(v => Breadcrumb.Iter(b => b.Text = v), this);

            UpLabel
            .Map(l => l.OnAction)
            .ToObservable()
            .Switch()
            .TakeUntil(disposed)
            .Subscribe(_ => this.GoUp());
            CloseLabel
            .Map(l => l.OnAction)
            .ToObservable()
            .Switch()
            .TakeUntil(disposed)
            .Subscribe(_ => this.Hide());

            Node.OnVisibilityChange()
            .StartWith(Visible)
            .TakeUntil(disposed)
            .Subscribe(OnVisibilityChanged, this);

            if (BackAction.IsSome)
            {
                Node.OnUnhandledInput()
                .Where(e => BackAction.Exists(v => e.IsActionPressed(v)) && this.CanGoUp())
                .TakeUntil(disposed)
                .Do(_ => Node.GetTree().SetInputAsHandled())
                .Subscribe(_ => this.GoUp(), this);
            }
        }