Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

State management #5467

Closed
danroth27 opened this issue Jan 25, 2018 · 14 comments
Closed

State management #5467

danroth27 opened this issue Jan 25, 2018 · 14 comments
Labels
area-blazor Includes: Blazor, Razor Components enhancement This issue represents an ask for new feature or an enhancement to an existing one Needs: Design This issue requires design work before implementating.
Milestone

Comments

@danroth27
Copy link
Member

No description provided.

@jmfury
Copy link

jmfury commented Feb 7, 2018

Hi Dan -

Super intrigued by this and if there was something I would get involved in it would be state management. I'm not super confident and will want to make sure I can be productive before trying to help, I can say I'm passionate about this. I have benefitted greatly from Microsoft's work in open source, and state management specifically.

One project I want to make you aware of is ReSub (by the Skype team I believe)..

https://github.com/Microsoft/ReSub

I have used this with prior iterations of Steve Sanderson's JavaScriptServices SPA templates for React. With Typescript's decorators it is a super clean experience especially when you compare it to Redux (cumbersome boilerplate code).

I will be reviewing the contribution guide and see if I can push on with some sort of paradigm similar to ReSub.. If I can't I'm sure the uber smart folks that will eventually jump in on your 'official experiment' will find some nice ways to get this done.

@johot
Copy link

johot commented Mar 24, 2018

I would love for this project to have state management that works like MobX (https://github.com/mobxjs/mobx). What I really love about MobX is that everything "just works", MobX tracks which components accessed what data and when that data is changed re-renders them. The best developer experience I've ever had!

@rynowak
Copy link
Member

rynowak commented Mar 25, 2018

@SteveSandersonMS is on vacation right now but I'll answer for him based on previous discussions...

This is something we're thinking about but not planning to build immediately. Blazor as it is it independent of a state management library.

What would be great would be to see a few community members take a stab at building something, and we can all learn from that.

@treg
Copy link

treg commented Mar 26, 2018 via email

@JohnLouderback
Copy link

I second something akin to Mobx

@campersau
Copy link
Contributor

campersau commented Mar 26, 2018

.NET has INotifyPropertyChanged and INotifyCollectionChanged so you can implement your own state / change detection based on them.
I have created a very simple demo application to demonstrate it.

It would be nicer though to only track changes on used properties instead of all of them.

@torhovland
Copy link

There is a Redux implementation available here:

https://github.com/torhovland/blazor-redux

It would be cool to also see something with automatic change tracking similar to Mobx using INotifyPropertyChanged.

@jirisykora83
Copy link

I make this example inspired with MobX with using INotifyPropertyChanged.

Most of boilerplate around INotifyPropertyChanged is generate with PropertyChanged.Fody which look great.

And observabed properties are mark like this.

@functions
{
	[Observable]
	public Passenger Passenger { get; set; }
}

Also you can use if you want observed only some properties.

[Observable(nameof(Models.Passenger.FirstName))]

@SteveSandersonMS
Copy link
Member

@jirisykora83 That's extremely interesting! Thanks for letting us know. @danroth27 We should consider this when we come up with designs for state management.

@jirisykora83
Copy link

@SteveSandersonMS If i understand correctly you are considering "Middleware for component activation and parameter passthrough" in #1 . If you decide to implement this then could be possible to add some state management without inhering from BlazorComponent (if we get option to call re-rendering from middleware).

I think it would be nice if you can just write something like app.UseStateX(); or app.UseBlazorRedux() in startup and do not need to inherits from same base component how most of the concept currently do.

@kekekeks
Copy link
Contributor

kekekeks commented Sep 1, 2018

@johot @JohnLouderback @campersau @jirisykora83 @SteveSandersonMS

Guys, I've created IL-instrumentation-based MobX "clone": https://github.com/kekekeks/NObservable

Unlike INotifyPropertyChanged-based approaches it tracks observed properties automatically and isn't limited to the component itself (it can observe changes from anywhere in the application)

It doesn't support all MobX's features yet, but @observable, autorun, when and runInAction counterparts are already available.

I've also integrated it with Blazor, the app and component structure looks like this. Basically you add @implements IObserverComponent to your component and NObservable will instrument BuildRenderTree and add its own ShouldUpdate implementation.

@aspnet-hello aspnet-hello transferred this issue from dotnet/blazor Dec 17, 2018
@aspnet-hello aspnet-hello added this to the Backlog milestone Dec 17, 2018
@aspnet-hello aspnet-hello added area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates enhancement This issue represents an ask for new feature or an enhancement to an existing one area-blazor Includes: Blazor, Razor Components labels Dec 17, 2018
@danroth27 danroth27 added the Needs: Design This issue requires design work before implementating. label Jan 4, 2019
@vertonghenb
Copy link
Contributor

The following repo is pretty interesting : https://github.com/TimeWarpEngineering/blazor-state, uses MediatR.

@mkArtakMSFT mkArtakMSFT removed area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates labels May 9, 2019
@guardrex
Copy link
Contributor

guardrex commented Jun 1, 2019

@rynowak This issue doesn't appear on the roadmap's backlog issue list: #8177

@mkArtakMSFT
Copy link
Member

Closing this issue as we have nothing concrete proposed here. If there is something specific you believe should be done here please file a new issue with your specific proposal.

@ghost ghost locked as resolved and limited conversation to collaborators Feb 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components enhancement This issue represents an ask for new feature or an enhancement to an existing one Needs: Design This issue requires design work before implementating.
Projects
None yet
Development

No branches or pull requests