For a live demo, visit www.stringconvert.com
What is it?
This is a simple demo that shows how use knockoutJs and the knockoutJs mapping plugin. While I was at it I added SignalR as well. Oh, stringConvert.com is a service that converts strings into other strings.
What's useful to look at?
Well, the cool thing with the knockoutJs mapping plugin is that you can take CLR types and serialize them to Json and load create a knockout view model from it. I'm doing a very simple version of that as you can see here and here.
The cool part about this is that I'm having StructureMap injecting all types that implement
IConvertStrings into the
converterRepository. When I implement a new converter it gets added automatically as usual using the injection, but it also gets added in my knockout view model since I load the serialized list.
The mapping plugin also lets me focus on behavior. I define properties in the CLR type which the mapping plugin automatically adds to the knockoutJs view model as observables. I implement functionality on the client side on the very same view model since the mapping plugin allows me to specify a target view model when mapping.
The SignalR part.
I wanted to have a go at the SignalR framework as well. The implementation here is not making use of all that it offers but some of it anyway. I use it to asynchronously execute the converters server side and when I get the response I update the result field. However, somewhat notable is that SignalR allows us to return a
Task<> which makes the async implementation really easy. Still, this could have been done using jQuery or whatever and I wanted to make at least one example of the cooler features that SignalR offers.
I came up with the very useful feature that shows the user the "Latests conversions", where I use the SignalR
Hub.Clients property to call a client side function from my CLR code. Note that it is called Clients and the effect is that I call the client side function on ALL the connected clients and this is where things become interesting.
Event though Nancy is an awesome MVC framework, this time I only used Nancy to look cool. There's no interaction between SignalR and Nancy and they are running side by side rather that together. I do have a feeling this will be sorted out soon though.
dotLess & Twitter Bootstrap
As a bonus I am happy to finally have got the Twitter Bootstrap less edition working with dotLess. I got a syntax error but it was just a qualifier that was weird and I guess it is a less dialect issue. I wrote a post about it on my sad sad blog.
That's about it I think. Enjoy. Questions: @mikaelOstberg
If you implement a converter, feel free to send a pull request. :)