All Projects → zewa666 → aurelia-async-binding

zewa666 / aurelia-async-binding

Licence: MIT license
Aurelia async bindingbehavior to consume Observables and Promises

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to aurelia-async-binding

aurelia-hoc-store
An Aurelia application showing the use of higher order components and a single state approach.
Stars: ✭ 20 (+5.26%)
Mutual labels:  rxjs, aurelia
House
Proof of Concept and Research repository.
Stars: ✭ 37 (+94.74%)
Mutual labels:  rxjs, aurelia
Store
Aurelia single state store based on RxJS
Stars: ✭ 103 (+442.11%)
Mutual labels:  rxjs, aurelia
aurelia-mdc-web
Aurelia wrapper for Material Design (Web) Components
Stars: ✭ 43 (+126.32%)
Mutual labels:  aurelia
community-events-angular
Community Events App built with ❤️ using Angular, NgRx, Rxjs to do thrill in #hacktoberfest21
Stars: ✭ 20 (+5.26%)
Mutual labels:  rxjs
aurelia-hacker-news
A recreation of the Hacker News website written in TypeScript and built with Aurelia.
Stars: ✭ 60 (+215.79%)
Mutual labels:  aurelia
react-redux-observables-boilerplate
Starter kit for React with Router, Redux, Observable + RxJS
Stars: ✭ 89 (+368.42%)
Mutual labels:  rxjs
angular-course
Angular Core Deep Dive (Video Course) - https://angular-university.io/course/angular-course
Stars: ✭ 193 (+915.79%)
Mutual labels:  rxjs
angular-8-alert-notifications
Angular 8 - Alert (Toaster) Notifications
Stars: ✭ 32 (+68.42%)
Mutual labels:  rxjs
rxeventstore
RxEventStore is a module for persisting and querying data using the Event Sourcing pattern and RxJs.
Stars: ✭ 26 (+36.84%)
Mutual labels:  rxjs
reactive-search
Incremental search using React and RxJS
Stars: ✭ 15 (-21.05%)
Mutual labels:  rxjs
rx-devtools
DevTools for RxJS
Stars: ✭ 30 (+57.89%)
Mutual labels:  rxjs
BittrexRx
BittrexRx is a rxjs node wrapper for the Bittrex Api
Stars: ✭ 16 (-15.79%)
Mutual labels:  rxjs
nabbitmq
Node.js library for interacting with RabbitMQ based on RxJS streams
Stars: ✭ 20 (+5.26%)
Mutual labels:  rxjs
ng-nest-cnode
Angular 10 Front-End and Nestjs 7 framework Back-End build Fullstack CNode
Stars: ✭ 17 (-10.53%)
Mutual labels:  rxjs
jasmine-marbles
Marble testing helpers for RxJS and Jasmine
Stars: ✭ 102 (+436.84%)
Mutual labels:  rxjs
aurelia-virtual-scroll
Aurelia Virtual Scroller
Stars: ✭ 15 (-21.05%)
Mutual labels:  aurelia
React-Redux-Enterprise
A React-Redux boilerplate for enterprise/large scaled web applications
Stars: ✭ 77 (+305.26%)
Mutual labels:  rxjs
aurelia-mdc-bridge
Aurelia Mdc Bridge is a collection of wrappers for Material Design Components.
Stars: ✭ 19 (+0%)
Mutual labels:  aurelia
RacJS
implementation of RAC(OC) on JavaScript and replacement of RxJS
Stars: ✭ 13 (-31.58%)
Mutual labels:  rxjs

aurelia-async-binding

npm Version Join the chat at https://gitter.im/aurelia/discuss CircleCI Coverage Status

An Aurelia binding behavior to consume async streams and promises directly from within your templates.

Install

Install the npm dependency via

npm install aurelia-async-binding

Configuration

In your main.ts you'll have to register the plugin which makes it globally available:

import {Aurelia} from 'aurelia-framework'
import environment from './environment';

export function configure(aurelia: Aurelia) {
  aurelia.use
    .standardConfiguration()
    .feature('resources');

  ...

  aurelia.use.plugin("aurelia-async-binding");  // <----- REGISTER THE PLUGIN

  aurelia.start().then(() => aurelia.setRoot());
}

Features

  • Easily access streamed values
  • Pluck complex object properties
  • Deep-plucking to access nested complex object properties using the dot-notation
  • Register completedHandler for once the stream completes
  • Register error handlers to react on streamed errors

Usage

Once the plugin is installed and configured you can use the async binding behavior. An example VM and View can be seen below:

import { Observable } from 'rxjs/Observable';
import "rxjs/add/operator/map";
import "rxjs/add/operator/take";
import "rxjs/add/observable/interval";
import "rxjs/add/observable/of";
import "rxjs/add/observable/from";

interface SPAFramework {
  label: string;
  url: string;
}
export class App {
  public frameworks: Observable<SPAFramework[]>;
  public frameworkOverTime: Observable<SPAFramework>;
  public isSequenceDone: boolean = false;

  constructor() {
    const data: SPAFramework[] = [
      { label: "Aurelia", url: "http://aurelia.io" },
      { label: "Angular v4", url: "http://angular.io" },
      { label: "React", url: "https://facebook.github.io/react/" },
    ];

    this.frameworks = Observable.of(data);

    this.frameworkOverTime = Observable.interval(2000)
      .map((idx) => data[idx])
      .take(data.length);
  }

  public completedHandler = () => {
    setTimeout(() => this.isSequenceDone = true, 2000);
  }
}
<template>
  <h1>SPA Frameworks</h1>
  <ul>
    <li repeat.for="framework of frameworks & async">
      <a href="${framework.url}">${framework.label}</a>
    </li>
  </ul>

  <h1>Frameworks streamed (plucked property)</h1>
  <div>
      ${frameworkOverTime & async: { property: 'label' }}
  </div>

  <h1>Frameworks streamed (with binding, completed handler)</h1>
  <div with.bind="frameworkOverTime & async: { completed: completedHandler }">
    <a if.bind="!isSequenceDone" href="${url}">${label}</a>
    <span if.bind="isSequenceDone">Sequence is done!</span>
  </div>
</template>

Acknowledgement

Thanks goes to Dwayne Charrington for his Aurelia-TypeScript starter package https://github.com/Vheissu/aurelia-typescript-plugin

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].