How to use Flux and event emitter with .net MVC?
Asked Answered
R

2

6

I am trying to learn the Flux pattern.

I learned to use React with .net MVC and rendered it server side.

I would like to learn Flux but all tutorials use node js.

I don't use node.

I don't know how to implement the Event Emitter part because it uses a node function.

https://www.codementor.io/reactjs/tutorial/react-js-flux-architecture-tutorial

About a 1/3 of the way down:

"Event Emitter – The event emitter is responsible for notifying subscribers after a store has completed any data action. Conversely, it also needs to be able to register observers for specific events. We’re going to be using Node’s event emitter in the todo application."

Given that Flux is simply a pattern, is there something that I can use with .net MVC, in the absence of node, to handle the Event Emitter part?

Thoughts appreciated, thanks.

Richert answered 23/7, 2015 at 23:51 Comment(1)
You should probably browserify your code so the node things are automatically resolved. It'll also make the same code work equally well on the client, and you avoid the whole concat or many-script tags problems. I don't know asp.net, so not sure if that's a viable option.Engler
S
1

You can use .NET Delegates, which is well documented here https://msdn.microsoft.com/en-us/library/edzehd2t%28v=vs.110%29.aspx

Delegates are multicast, which means that they can hold references to more than one event-handling method.

This will of course be a server-side implementation of the Flux pattern.

Soredium answered 24/7, 2015 at 14:3 Comment(0)
T
1

We do use the flux pattern on the client side without having node.js installed on our web servers. In order to do this we have to use Node.js at build time on our Team City CI servers to run a gulp task that pushes the .jsx files through the jsx interpreters and spit out a raw js file. Now our flux application is a essentially a static .js file that has already been interpreted by Node.js

Tlemcen answered 7/8, 2015 at 20:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.