Skip to content

ReactiveUI.Blazor Server, ViewModel Activation, and JSRuntime #3564

Closed Answered by chrisg32
chrisg32 asked this question in Q&A
Discussion options

You must be logged in to vote

The solution is to create a custom IActivationForViewFetcher. A complete example of how to do this is available in Sample 18.05 of You, I, and ReactiveUI. Shout out to @kentcb for an excellent book . If I would have kept reading I would have found the answer sooner. 🤦‍♂️

My implementation is below.

IActivationForViewFetcher

public class ActivationAfterRenderForViewFetcher : IActivationForViewFetcher
{
    public int GetAffinityForView(Type view)
    {
        return typeof(ICanRender).IsAssignableFrom(view) ? 100 : 0;
    }

    public IObservable<bool> GetActivationForView(IActivatableView view)
    {
        var activation =
            GetActivationFor(view as ICanRender) ??
          …

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
1 reply
@chrisg32
Comment options

Answer selected by chrisg32
Comment options

You must be logged in to vote
3 replies
@chrisg32
Comment options

@glennawatson
Comment options

@chrisg32
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants