Question

I've been using Linq for a while unknowingly that it uses a Reactive pattern that I'm quite fond of.

I'd like to roll my own function in that pattern but wasn't sure if it's appropriate and also wanted to throw out ideas about how I would do it.

My goal is to make a video player service that is injecte dinto classes, the service contains a function which plays a video but the user can do other things, something like:

videoPlayer.Play(videoClip).StartAt(3).EndAt(8).OnUpdate((event)=>{}).Finish((event)=>{})

Does this make sense for reactive programming and how would I go about implementing it in C#? My thought was videoPlayer.Play returns a class with all the functions such as StartAt and EndAt which in turn return the same class object.

Would that be the way to do it?

Was it helpful?

Solution

That is not reactive programming. Reactive programming is something entirely different.

What you have is called fluent interface. And it is quite trivial to implement in C#.

Licensed under: CC-BY-SA with attribution
scroll top