I have a project that i right now have set up with BreezeJS. Not knowing what goes on inside BreezeJS to the full scope, but just accepted that it works, i have my items shown on screen basically from this simple command.
export function getProjects(projectsObservable, errorObservable)
{
return breeze.EntityQuery.from("Projects")
.using(manager).execute()...then/fail.
}
I now want to make it responsiveness to users that edit the same items with signalR. This means i at this point have callbacks being fired on javascript end saying that object with guid = xxxxxxx has changed(guid is the key).
How can i tap into Breeze updating the item without it query the server again, nor sees it as an update that needs to be send back to the server. Remmeber that i just got the update from signal r.
Should i have taken another path in the first place, is there a reason to create a WebApi if i could just could have returned the data from the signalR hub at the beginning? Would it be easy to set this up with Breeze instead of the WebApi ?
We at IdeaBlade are looking forward to providing good guidance on Breeze apps working with SignalR.
My current thinking is that SignalR is appropriate for notifying the client of changes to data of interest but I would not deliver the changed data to the client with SignalR. I let the client decide whether (or not ... or when) to get the changed data from the server.
My reasoning is based on the view that SignalR should be a fast, lightweight mechanism for notification, not a fire hose spraying vast quantities of data at subscribing clients who may or may not be ready (or willing) to cope with a huge volume of change data forced upon them.
Perhaps you can elaborate on why you think differently. I'm certainly open to an alternative perspective.
I totally agree with Ward Bell
If you wonder how to do it: for example in an angular Application , you could subscribe to breeze entity tracking mechanism like this
Then you could setup a SignlarR Hub someplace else to transmit those changes to all clients
However possible thanks to the power of breeze.js, I would not recommend it, because as Ward pointed out : “that will be a fire hose spraying vast quantities of data at subscribing clients” . Just think for a moment, and consider your application will have hmmm let’s say 30 concurrent users doing transactions , imagine all the Network traffic that will be creating. That will be bad software architecture.
The only reason you may consider doing this is if you need to update a dashboard that feeds from live data, but still you need to be extra concision,mindful, aware, cognizant of the data traffic and server utilization .
function setupEventForHasChangesChanged() {
EntityManager.hasChangesChanged.subscribe(function (eventArgs) {
$rootScope.$emit('dataservice.hasChangesChanged', eventArgs);
});
}
function setupEventForEntitiesChanged() {
EntityManager.entityChanged.subscribe(function (changeArgs) {
if (changeArgs.entityAction === breeze.EntityAction.PropertyChange) {
$rootScope.$emit('dataservice.entitiesChanged', changeArgs);
}
});
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With