Scritchy and SignalR

77 views
Skip to first unread message

Michael Borisov

unread,
Oct 27, 2013, 7:07:25 AM10/27/13
to scri...@googlegroups.com
Hi Tom,

I'm really interested to try the Scritchy for one of my projects.
This is a web based application.
There are NancyFX with OWIN and Scritchy on a server side.
Client is angularjs with postaljs.
I need to implement a single event listener which passes all events from the server to a client.
I know that I need to make it more complicated in future. But for now it should work like a charm.
So, the question is how would you do that using Scritchy?

Thank you,
Michael.

Tom Janssens

unread,
Oct 28, 2013, 3:29:28 AM10/28/13
to scri...@googlegroups.com
Hey Michael,

Thanks; glad you like it...
Have you taken a look at the example app? https://github.com/ToJans/Scritchy/tree/master/Example.Web

Does this somehow provide what you need? Or could you be more specific?

Tom

Op zondag 27 oktober 2013 12:07:25 UTC+1 schreef Michael Borisov:

Michael Borisov

unread,
Oct 28, 2013, 5:32:45 AM10/28/13
to scri...@googlegroups.com
Hi Tom,

Thank you for the fast replay!

Yes I had a look on the example. It works quite nice when you need to publish some events.
But I'd like to publish all events on SignalR client with a single handler.
I'm too lazy to write a separate handler method for every event I have in a system.

I actually found how to do that. I've implemented my own CommandBus and in a RunCommand method after command processing I publish all new events to a SignalR hub.

I also have a suggestion.
Currently handler registry resolves handlers only by exact event type match.
What if it can resolve assignable event types as well?
Then it would be possible define a base event and a handler that can process all events inherited from the base event.
May be there is a reason to not to do that.
I'd be happy to know your opinion.

With best wishes,
Michael.

Tom Janssens

unread,
Oct 28, 2013, 7:42:29 AM10/28/13
to scri...@googlegroups.com
Answers below

Op maandag 28 oktober 2013 10:32:45 UTC+1 schreef Michael Borisov:
Hi Tom,

Thank you for the fast replay!

You are welcome, I am glad the lib is useful for you! 

Yes I had a look on the example. It works quite nice when you need to publish some events.
But I'd like to publish all events on SignalR client with a single handler.
I'm too lazy to write a separate handler method for every event I have in a system.

I actually found how to do that. I've implemented my own CommandBus and in a RunCommand method after command processing I publish all new events to a SignalR hub.

Perfect! Glad to hear it works out for you! All the components should be pretty straightforward and easy to replace if I recall it correctly.

I also have a suggestion.
Currently handler registry resolves handlers only by exact event type match.
What if it can resolve assignable event types as well?
Then it would be possible define a base event and a handler that can process all events inherited from the base event.
May be there is a reason to not to do that.
I'd be happy to know your opinion.

That would be a very good idea actually, probably using Type.IsAssignableFrom? I will not do it right now, but do feel free to submit a pull request ;-)
Reply all
Reply to author
Forward
0 new messages