From bdfed9d850d6593b1f7f7735b6a6bf2ff1beb4bf Mon Sep 17 00:00:00 2001 From: Tim Ruffles Date: Thu, 19 Nov 2015 15:17:35 -0800 Subject: [PATCH] docs(core): make naming concrete I think people new to promises, angular etc will find this example easier to understand with concrete identifiers from a simple use-case. The existing naming could be confused with promise/angular functionality (`promise` in the template, `resolved` etc). Also I made `resolve` private, as then it's clear what we're exposing for the template. --- .../pipes/ts/async_pipe/async_pipe_example.ts | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/modules/angular2/examples/core/pipes/ts/async_pipe/async_pipe_example.ts b/modules/angular2/examples/core/pipes/ts/async_pipe/async_pipe_example.ts index 89c8342dd7..3cb7e93d5e 100644 --- a/modules/angular2/examples/core/pipes/ts/async_pipe/async_pipe_example.ts +++ b/modules/angular2/examples/core/pipes/ts/async_pipe/async_pipe_example.ts @@ -5,28 +5,29 @@ import {bootstrap} from 'angular2/bootstrap'; @Component({ selector: 'async-example', template: `
-

Wait for it... {{promise | async}}

- +

Wait for it... {{ greeting | async }}

+
` }) export class AsyncPipeExample { - resolved: boolean = false; - promise: Promise = null; - resolve: Function = null; + greeting: Promise = null; + arrived: boolean = false; + + private resolve: Function = null; constructor() { this.reset(); } reset() { - this.resolved = false; - this.promise = new Promise((resolve, reject) => { this.resolve = resolve; }); + this.arrived = false; + this.greeting = new Promise((resolve, reject) => { this.resolve = resolve; }); } clicked() { - if (this.resolved) { + if (this.arrived) { this.reset(); } else { - this.resolve("resolved!"); - this.resolved = true; + this.resolve("hi there!"); + this.arrived = true; } } }