I am looking at MVVM with Knockout.js. One of the things I would like to achieve is to "easily" get my code behind MVVM POCO to the client as a corresponding JS object.
The idea being that:
a) If I change the C# POCO it will also reflect in the JS Object
b) Changing a value in the POCO will result in the necessary interaction with the client to update the JS object
I am guessing this is when you would use SignalR (http://signalr.net/) to do this? And then use the mapping plugin from KO (http://knockoutjs.com/documentation/plugins-mapping.html) to turn this into observables.
So my questions are:
Are my assumptions correct in terms of getting the POCO server
side data to KO via SignalR
Is there another way to achieve 1.?
Yes, you can use SignalR to push real-time changes to the POCO representation of your object to the client. I mean, it won't be automatic in terms of you change a property, it magically sends a message. You would have to build some plumbing to ensure you send a specific SignalR message when a particular object changed. You could choose to resend the entire representation of that object again (e.g. all current values) or you could send only the values that you know were changed for more efficiency.
From there you would need to update the corresponding JS representation of the object which, if you're using Knockout, would result in the proper notifications to all observers of said object. You could also do this in the other direction by observing a change on the JS object and sending a message back to the server.
Obviously the key will be that each object must have some kind of unique identity so that you can correlate the messages to/from the proper JS/POCO objects.
Related
I am using Axon 3.1.1 and wanted to know,
How can I get a list of eventprocessor in my configuration file,
I went through the springAmQPmessageSource file but still not sure how to exactly do it.
So that I can pass my event to appropriate eventhandler on Query side.
List<Consumer<List<? extends EventMessage<?>>>> eventProcessors = new CopyOnWriteArrayList<>();
Updated
I was retrieving message from kafka topic and wanted to wire them to specific eventhandler but since I am not able to get evenprocessors, I am not able to do that.
Can you please tell me how to do it, if I am using Axon 3.0.5
If you're using the SpringAmqpMessageSource, you will not need to retrieve the list of eventProcessors you've shared, as Axon will automatically subscribe all the event handling components to it for you.
Subsequently, the events the Message Source receives will automatically be pushed to all the listeners in your query side.
As this is all covered as Axon infrastructure under the hood, there is no one-off way to pull them out of it for your own use (other than potentially wiring them yourself).
Hence, you shouldn't have to do this yourself.
But, maybe I'm missing an obvious point here.
Could you elaborate a little more why you need the list of handlers in the first place?
I am using a custom AuthAttribute to determine whether a user can access a controller and/or actions. The problem is I have to duplicate information and EFx connections in the attribute that already exist on the class that is being adorned.
My question is whether there is a way to access the fields on the adorned class from the custom AuthAttribute? I am trying to avoid having to re-architect the software in a way that would provide a single point of access since that would open up a different can of worms.
I believe I have found an answer that works. I welcome all comments on this solution.
Rather than have the attribute gain access to the properties and fields on the controller it adorns you can share values between them in a thread-safe way through the common HttpContext object. So if you are being extreme like I am and are trying to cut down on duplicate calls to your database in both the authattribute and the adorned controller action then pass the results forward. What that means is the authattribute will be called first and you can stash the retrieved values in the "Items" collection off the HttpContext object passed into the AuthorizeCore(..) method. You can then retrieve the same value in a THREAD-SAFE way through the HttpContext object in the controller.
example to save value within the AuthorizeCore(..) override of the AuthAttribute:
httpContext.Items.Add("fester", "bester");
example to retrieve value inside the subsequent call to the Controller/Action:
this.HttpContext.ApplicationInstance.Context.Items["fester"];
I have to warn you this is only a possible implementation that appears to work in simple testing. Personally it feels like a hack and there has to be a better way. I would also state this is in pursuit of a dubious performance benefit. It should cut down on the number of database and/or network calls by cache'ing retrieved data in the HttpContext so you don't have to repeat the calls in both the authattribute and the adorned Controller/Action. If you don't have a web site that gets a huge volume of calls then I would warn you against this.
I hope someone recommends something better on this page. I will keep an eye on how this works on my web site and let y'all know if it behaves and is truly thread-safe.
I'm working on a GWT project which calls the server via RPC. A typical RPC calls the Server and passes some information and then recieves the answer as an ArrayList.Now we noticed that with a growing database we should use pagination to not overcharge the client with to many objects.
The problem is that there are at the moment many existing methods which are using RPC and each of them would must be modified to provide the necessary information for pagination (Count of Objects,Current Position ) . If i would change every method i would have to edit the Synchronous Interface,the Asynchronous Interface, and the Server and Client class which are using/implementing them.
I tried to create a generic Wrapper class, but i couldn't make it suitable for out project,because each object must be casted back in the original type. Is there a way with less effort to provide pagination without editing many methods?
I have an application which must save client instances of com.smartgwt.client.widgets.Canvas to a disk on the server, and then restore them.
My solution is to serialize the canvases, send them to the server to be saved, save them, load them, send them back to the client, and then deserialize.
Currently, the network transfer code is all in place. The only thing left is serializing the canvases. However, I want to know if doing so is even possible? If not, any workarounds? Clues?
Thanks,
Ian
I would suggest that you do not serialize the Canvases themselves, but instead save their state. Depending on what the canvases contain, this can be easier or harder, but in most cases makes better sense than trying to save the objects themselves. SmartGWT provides API calls to save the state of some complex object, e.g. ListGrids . For simpler objects you can come up with a way to store their view state, e.g by using a JSON object that holds of what is important to your case.
Does anyone know if it is possible to write to the response stream in OpenRasta rather than returning an object as a response resource? Alternatively, am I able to implement an HTTP handler but still leverage OpenRasta's URL rewriting?
Thanks
Chris
You can always keep an http handler on the side to do specialized things, but that ties you to asp.net and will prevent your code from being portable on other hosts. If that's something you're ok with, any handler that's registered for a specific route will get executed before openrasta on asp.net.
that said, codecs are the ones writing to the response stream, so provided you have a custom IMediaTypeWriter you can write the resource instance on a stream whichever way you want.
Say for example that you returned an IEnumerable from your handler, as those get deferred executed, you can just start the enumeration of those in your custom codec without any problem.