Giter VIP home page Giter VIP logo

angular2-flux's Introduction

Angular2: Flux and Observable Example

This example shows how to implement the flux pattern in Angular 2 using observables.

It's accompanied by a blog post to run through the implementation.

You can read the post on the ovo tech blog.

Getting Started

Make sure you have the typescript compiler installed (npm install -g tsc).

Install all the dependencies with

npm install

Then, in one window run the compiler in watch mode on the src/ directory.

tsc -p src -w

In another window start the app with

npm start

angular2-flux's People

Contributors

edconolly avatar

Stargazers

Gerard Sans avatar

Watchers

James Cloos avatar  avatar

Forkers

seandjones

angular2-flux's Issues

"notify" drops previous listeners when a new one connects

The way the Observables are set up in Dispatcher#18-20 and HeroesStore#17-19 only ever allows a single listener on the observables. Since on every new subscriber connection the notify object is overwritten, only the latest connected subscriber will get updates.

In this example this is not a problem since there is only ever one subscriber per observable, but when more than one subscriber is listening to e.g. the Dispatcher, or the Store, this pattern does not work. The notify method has to be replaced with either a list of listeners, or the observable should be replaced with a Subject on which we can call .next() and which automatically handles connections and notification.

I'm mentioning this because I spent an hour yesterday trying to debug why my listeners weren't being called when I used this pattern, and want to avoid others having the same problem...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.