From 49d2baa2fd9d2a143d43e915c7d45f8c50be3fac Mon Sep 17 00:00:00 2001 From: "Wortmann, Jan-Niklas" Date: Thu, 14 Dec 2017 22:38:36 +0100 Subject: [PATCH 1/2] docs(operators): add documentation for last add documentation and an example for the last operator close #94 --- src/operator-docs/filtering/last.ts | 45 +++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/src/operator-docs/filtering/last.ts b/src/operator-docs/filtering/last.ts index ca2c73a2..4417f095 100644 --- a/src/operator-docs/filtering/last.ts +++ b/src/operator-docs/filtering/last.ts @@ -1,6 +1,47 @@ import { OperatorDoc } from '../operator.model'; export const last: OperatorDoc = { - 'name': 'last', - 'operatorType': 'filtering' + name: 'last', + operatorType: 'filtering', + signature: 'public last(predicate: function): Observable', + useInteractiveMarbles: true, + parameters: [ + { + name: 'predicate', + type: 'function', + attribute: '', + description: 'The condition any source emitted item has to satisfy.' + } + ], + marbleUrl: 'http://reactivex.io/rxjs/img/last.png', + shortDescription: { + description: `Emits only the last value emitted by the source Observable.` + }, + walkthrough: { + description: `

+ last Returns an Observable that emits only the last item emitted by the source Observable. +

+

+ It optionally takes a predicate function as a parameter, + in which case, rather than emitting the last item from the source Observable, + the resulting Observable will emit the last item from the source Observable that satisfies the predicate. +

` + }, + examples: [ + { + name: 'Get the last number that is divisible by 3', + code: ` + const range = Rx.Observable.range(1, 10); + const last = range.last(x => x % 3 === 0); + last.subscribe(x => console.log(x)); + // Logs below values + // 9 + `, + externalLink: { + platform: 'JSBin', + url: 'http://jsbin.com/reqacoselu/edit?html,js,console' + } + } + ], + relatedOperators: ['takeLast', 'first'] }; From 0191a7e4897596f07bac504c39e2c52f2a0d9237 Mon Sep 17 00:00:00 2001 From: "Wortmann, Jan-Niklas" Date: Fri, 15 Dec 2017 08:39:48 +0100 Subject: [PATCH 2/2] docs(operators): change jsbin link to embedded --- src/operator-docs/filtering/last.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/operator-docs/filtering/last.ts b/src/operator-docs/filtering/last.ts index 4417f095..8fb81065 100644 --- a/src/operator-docs/filtering/last.ts +++ b/src/operator-docs/filtering/last.ts @@ -39,7 +39,7 @@ export const last: OperatorDoc = { `, externalLink: { platform: 'JSBin', - url: 'http://jsbin.com/reqacoselu/edit?html,js,console' + url: 'http://jsbin.com/reqacoselu/embed?html,js,console' } } ],