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.
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.
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
来源:https://stackoverflow.com/questions/31599992/how-to-use-flux-and-event-emitter-with-net-mvc