RealTimeWeb
268 views | +0 today
Follow
Your new post is loading...
Your new post is loading...
Rescooped by Andrew H Choi from JavaScript for Line of Business Applications
Scoop.it!

Complementing SignalR's real-time communication with Knockout.js

Complementing SignalR's real-time communication with Knockout.js | RealTimeWeb | Scoop.it

n line with proper software design practices, we want code that has clean separation of concerns and is easily testable. This code runs counter to those goals. If we take a closer look at the file, we can see several reasons why. The most obvious culprit is the huge chunk of HTML markup assigned to the rowTemplate variable, a clear violation of separation of concerns. The lack of testability is slightly more subtle, and there are actually two issues that make this code difficult to test. The first issue is that everything is scoped to jQuery’s .ready method, so there is no public surface area for a test framework to hook into. The second issue deals with the jQuery selectors that are used to find and update specific DOM elements — which wouldn’t exist in a test environment where our JavaScript code is being run in isolation, in a headless browser. So what can we do to fix these issues?

 

This example is an excellent candidate for refactoring to use the MVVM pattern. We’ve had great success with this pattern on the FNC.br project, and more specifically with the Knockout.jsframework. In this post, I’ll show you how to modify the stock ticker example in the Microsoft tutorial using MVVM, resulting in testable code with cleanly separated concerns. The SignalR messages we receive are essentially an observable stream of events, which fits perfectly with Knockout’s Observable/Observer paradigm. These messages will serve as our Model. Our View will be the StockTicker.html page, with declarative Knockout bindings in place of the “poor man’s templating” solution used in the tutorial.  And finally, for our ViewModel, we’ll create a pure JavaScript code file with enough of a public interface to test. Let’s get started.


Via Jan Hesse
more...
No comment yet.
Rescooped by Andrew H Choi from .Net & Web Development
Scoop.it!

CQRS Event Sourcing pattern with NServiceBus, ASP.NET MVC and SignalR

CQRS Event Sourcing pattern with NServiceBus, ASP.NET MVC and SignalR | RealTimeWeb | Scoop.it

The server side is located in the cloud and interacts with a client through event handlers which are deployed in some web application. Further, received messages are distributed to different types of client applications via SignalR: client initiates communication; server uses opened socket to return data to the client; client uses keep-alive to preserve open connection. In such a way, the CQRS events processing is provided.

 

 

 


Via William delmas
more...
No comment yet.
Rescooped by Andrew H Choi from JavaScript for Line of Business Applications
Scoop.it!

Realtime Wall Post and Comment Notifications using SignalR and Knockout

Realtime Wall Post and Comment Notifications using SignalR and Knockout | RealTimeWeb | Scoop.it
implementing real time notifications similar to twitter, stackoverflow..etc using Knockout JS and SignalR.

In this post, we will implement real time notification when any new post or comment is added and display it on notification click using Knockout JS and SignalR. You might think .. Why notification? Why not to display in real time? If we display it in real time, It will irritate users. Suppose you are reading a post middle of the page, suddenly few new posts appear on top then the post you are reading go down and you have to scroll down to find where it is. That’s why in twitter or Stackoverflow,the notification is used when any new post is arrived and you can check them on notification click. We will implement the same thing for both posts and comments.


Via Jan Hesse
more...
No comment yet.
Scooped by Andrew H Choi
Scoop.it!

Real-Time Web Applications with ASP.NET WebAPI and SignalR

www.epcgroup.net | sharepoint@epcgroup.net | Phone: (888) 381-9725 * SharePoint Server 2013, SharePoint Server 2010, and SharePoint 2007: Review, Architectur...
more...
No comment yet.
Rescooped by Andrew H Choi from JavaScript for Line of Business Applications
Scoop.it!

Using SignalR and knockout.js to push data in real-time to the browser

Using SignalR and knockout.js to push data in real-time to the browser | RealTimeWeb | Scoop.it

One of the most exciting developments in web technology of the past year is, in my opinion, the development of cross-browser javascript socket libraries and the addition of web sockets as part of the HTML5 standard. Although push communication has been available for a long time, it was hard to implement, used proprietary technologies and was hindered by performance and scalability problems. But libraries like socket.io and services like Pusher have changed this and have made implementing two-way communications on the web very simple. I feel that we are just at the beginning of a new generation of exciting web applications.

For our cloud auction project, we want to use web sockets to send price, availability and product updates from the server to all active clients. It’s important that these updates are synchronized as much as possible, so that every user sees the same price at the same time. We want to avoid users hammering our servers by refreshing the page in their browser, pressing F5 every second. We are starting from our ASP.NET MVC cloud auction website, a standard website based on the MVC Internet Website template. I described several parts of it in other posts in this series.


Via Jan Hesse
more...
No comment yet.
Rescooped by Andrew H Choi from JavaScript for Line of Business Applications
Scoop.it!

Building a shopping cart with SignalR, ASP.NET Web API and Knockout.js

Building a shopping cart with SignalR, ASP.NET Web API and Knockout.js | RealTimeWeb | Scoop.it

In this tutorial we will go through a process of building a sample shopping cart with real time capabilities. On top of that, we'll also throw in a real time admin order overview.

The technologies used will include:

* Knockout.js - for reactive client side data binding

* ASP.NET Web API - as an API to retrieve data and send orders to the server side

* SignalR - to notify interested parties in changes to the item stock quantities & order status

 

Since the topic of building a functional e-commerce solution is obviously extremely broad, we will take a few simplifications, which will allow us to focus our attention on the real time aspects of the cart and avoid distractions. We will treat security (user login/logout) and data persistence (we'll just store the data in memory) as out of scope.


Via Jan Hesse
more...
No comment yet.
Rescooped by Andrew H Choi from JavaScript for Line of Business Applications
Scoop.it!

RealTime Charts With Wijmo & KnockoutJS

RealTime Charts With Wijmo & KnockoutJS | RealTimeWeb | Scoop.it

Most web-developers know about KnockoutJS, and I hope that most of them have heard about (or used) the amazing stuff that Wijmo delivers. If you do not know about Wijmo, here a short summary…

The goal with this post/tutorial is (as stated above) to create a Wijmo line-chart and make it alive with some real-time data. To have some data to display I will just randomize some numbers server-side.

NOTE: If you want to implement a working example your self, now is the time to create a new Visual Studio project (MVC3/MVC4) and add a default.html to the root of the project.


Via Jan Hesse
more...
No comment yet.