RxJS: Cache data in Angular

October 21, 2017

One of the common tasks in building client application is getting data from the server and displayed to the client in some sort of data presentation: list, form, etc. Usually, retrieved data is stored in the internal memory so it can be presented multiple times without re-retrieving it from the server: cache.

Angular based client is no different in this case. This article is about simple class Cacheable<> that helps managing cache of data retrieved from http server or other any other source. This class can:

  • Trigger “get data” request when no cache available
  • Store retrieved data in the cache
  • Get data to the client as Observable
  • Reset cache

Please see final version with example how to use it on Plunker.

Read More ...

RxJS: Making simple variable as Observable

September 21, 2017

It is hard to build application with Angular without taking advantage of Observables. There is a bunch examples of handling http requests using them in the web.

Sometimes we need to use them to handle simple values. In the case it is usually implemented in a service. Service needs to provide Observable reference so components can subscribe for the updates. It requires at least two members declared in the service: Subject & Observable. Having half dozen observables in the service produces a dozen of declaration and makes code cluttered.

Read More ...

Angular2 "Tour of Heroes" with ASP.NET MVC Core

November 06, 2016

Sometimes it is not easy to decide what pattern to choose between single-page application (SPA) or traditional HTML pages. What if you need SPA only for the particular part of your website?

In general, mixing these two is not recommended. But if you have an existing traditional web app with tons of pages – conversion will not be easy and should be done in multiple steps.

So, I had the challenge migrating big ASP.NET MVC project to Angular2. As result I decided to share my experience and create a sample of Angular2 “Tour of Heroes” running as ASP.NET MVC Core:


Read More ...