GithubHelp home page GithubHelp logo

rlittlesii / reactiveui.showroom Goto Github PK

View Code? Open in Web Editor NEW
9.0 3.0 1.0 13.52 MB

A repository to show case the features of the ReactiveUI platform.

License: MIT License

C# 99.43% PowerShell 0.31% Shell 0.25%
xamarin-forms mvvm reactiveui

reactiveui.showroom's Introduction

reactiveui.showroom's People

Contributors

nightowlcoder avatar rlittlesii avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

nightowlcoder

reactiveui.showroom's Issues

question: about Observable subscription dispose in the View Models

Instead of an actual issue here, I have a question regarding the observable subscription dispose in the View Models.
Not sure if it is appropriate to ask a question here.

When I was playing with this repo, I found most of the observable subscriptions in the view models are ending with call DisposeWith().

Take InfiniteScrollViewModel.cs as an example (#47 - #77)

            _inventoryDataService
                .ChangeSet
                .Transform(x =>
                    new InventoryItemViewModel
                    {
                        Id = x.Id,
                        Brand = x.BrandName,
                        Coffee = x.CoffeeName,
                        Roast = x.Roast,
                        Packaging = x.Packaging
                    })
                .AutoRefresh(x => x.Id)
                .DeferUntilLoaded()
                .Filter(searchChanged)
                .Sort(SortExpressionComparer<InventoryItemViewModel>.Descending(x => x.Roast))
                .Page(_pagingSubject.AsObservable())
                .ObserveOn(RxApp.MainThreadScheduler)
                .Bind(out _items)
                .DisposeMany()
                .Subscribe()
                .DisposeWith(ViewModelSubscriptions);

            this.WhenAnyObservable(x => x.Refresh.IsExecuting)
                .StartWith(false)
                .DistinctUntilChanged()
                .ToProperty(this, nameof(IsRefreshing), out _isRefreshing, deferSubscription: true)
                .DisposeWith(ViewModelSubscriptions);

            this.WhenAnyObservable(x => x.Load.IsExecuting)
                .ToProperty(this, nameof(IsLoading), out _isLoading, deferSubscription: true)
                .DisposeWith(ViewModelSubscriptions);

By reading the document from ReactiveUI https://www.reactiveui.net/docs/guidelines/framework/dispose-your-subscriptions, it seems like the last two subscriptions are unnecessary to dispose. But the first one is necessary as it will cause the VM to have the reference with _inventoryDataService.

Not sure if my understanding is correct. Thanks for clarification.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.