Skip to content

Commit 0ed0d8e

Browse files
[added] named exports for IndefiniteObservable and wrapWithObserver
Reviewers: O2 Material Motion, O3 Material JavaScript platform reviewers, #material_motion Tags: #material_motion Differential Revision: http://codereview.cc/D3495
1 parent d5af3ce commit 0ed0d8e

11 files changed

+112
-32
lines changed

dist/IndefiniteObservable.d.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,28 @@
1+
/** @license
2+
* Copyright 2016 - present The Material Motion Authors. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
5+
* use this file except in compliance with the License. You may obtain a copy
6+
* of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations
14+
* under the License.
15+
*/
116
import { Connect, Observable, ObserverOrNext, Subscription } from './types';
217
/**
3-
* Observable is a standard interface that's useful for modeling multiple,
18+
* `Observable` is a standard interface that's useful for modeling multiple,
419
* asynchronous events.
520
*
6-
* IndefiniteObservable is a minimalist implementation of a subset of the TC39
21+
* `IndefiniteObservable` is a minimalist implementation of a subset of the TC39
722
* Observable proposal. It is indefinite because it will never call `complete`
823
* or `error` on the provided observer.
924
*/
10-
export default class IndefiniteObservable<T> implements Observable<T> {
25+
export declare class IndefiniteObservable<T> implements Observable<T> {
1126
private _connect;
1227
/**
1328
* The provided function should receive an observer and connect that
@@ -31,3 +46,4 @@ export default class IndefiniteObservable<T> implements Observable<T> {
3146
*/
3247
subscribe(observerOrNext: ObserverOrNext<T>): Subscription;
3348
}
49+
export default IndefiniteObservable;

dist/IndefiniteObservable.js

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/indefinite-observable.js

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,22 @@
1414
* under the License.
1515
*/
1616
"use strict";
17-
17+
"use strict";
18+
/** @license
19+
* Copyright 2016 - present The Material Motion Authors. All Rights Reserved.
20+
*
21+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
22+
* use this file except in compliance with the License. You may obtain a copy
23+
* of the License at
24+
*
25+
* http://www.apache.org/licenses/LICENSE-2.0
26+
*
27+
* Unless required by applicable law or agreed to in writing, software
28+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
29+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
30+
* License for the specific language governing permissions and limitations
31+
* under the License.
32+
*/
1833

1934
/** @license for symbol-observable:
2035
* The MIT License (MIT)
@@ -74,10 +89,10 @@ var $observable = (
7489
)();
7590

7691
/**
77-
* Observable is a standard interface that's useful for modeling multiple,
92+
* `Observable` is a standard interface that's useful for modeling multiple,
7893
* asynchronous events.
7994
*
80-
* IndefiniteObservable is a minimalist implementation of a subset of the TC39
95+
* `IndefiniteObservable` is a minimalist implementation of a subset of the TC39
8196
* Observable proposal. It is indefinite because it will never call `complete`
8297
* or `error` on the provided observer.
8398
*/
@@ -125,7 +140,33 @@ class IndefiniteObservable {
125140
return this;
126141
}
127142
}
143+
exports.IndefiniteObservable = IndefiniteObservable;
144+
145+
"use strict";
146+
/** @license
147+
* Copyright 2016 - present The Material Motion Authors. All Rights Reserved.
148+
*
149+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
150+
* use this file except in compliance with the License. You may obtain a copy
151+
* of the License at
152+
*
153+
* http://www.apache.org/licenses/LICENSE-2.0
154+
*
155+
* Unless required by applicable law or agreed to in writing, software
156+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
157+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
158+
* License for the specific language governing permissions and limitations
159+
* under the License.
160+
*/
128161

162+
/**
163+
* TypeScript is a pain to use with polymorphic types unless you wrap them in a
164+
* function that returns a single type. So, that's what this is.
165+
*
166+
* If you give it an observer, you get back that observer. If you give it an
167+
* anonymous function, you get back that anonymous function wrapped in an
168+
* observer.
169+
*/
129170
function _wrapWithObserver(listener) {
130171
if (typeof listener === 'function') {
131172
return {
@@ -136,4 +177,4 @@ function _wrapWithObserver(listener) {
136177
return listener;
137178
}
138179
}
139-
180+
exports._wrapWithObserver = _wrapWithObserver;

dist/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@
1515
*/
1616
export * from './types';
1717
export * from './IndefiniteObservable';
18+
export { wrapWithObserver } from './wrapWithObserver';
1819
export { default as IndefiniteObservable } from './IndefiniteObservable';

dist/index.js

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/types.js

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/wrapWithObserver.d.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,13 @@
1414
* under the License.
1515
*/
1616
import { Observer, ObserverOrNext } from './types';
17-
export default function wrapWithObserver<T>(listener: ObserverOrNext<T>): Observer<T>;
17+
/**
18+
* TypeScript is a pain to use with polymorphic types unless you wrap them in a
19+
* function that returns a single type. So, that's what this is.
20+
*
21+
* If you give it an observer, you get back that observer. If you give it an
22+
* anonymous function, you get back that anonymous function wrapped in an
23+
* observer.
24+
*/
25+
export declare function wrapWithObserver<T>(listener: ObserverOrNext<T>): Observer<T>;
26+
export default wrapWithObserver;

dist/wrapWithObserver.js

Lines changed: 11 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/IndefiniteObservable.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ import {
2727
} from './types';
2828

2929
/**
30-
* Observable is a standard interface that's useful for modeling multiple,
30+
* `Observable` is a standard interface that's useful for modeling multiple,
3131
* asynchronous events.
3232
*
33-
* IndefiniteObservable is a minimalist implementation of a subset of the TC39
33+
* `IndefiniteObservable` is a minimalist implementation of a subset of the TC39
3434
* Observable proposal. It is indefinite because it will never call `complete`
3535
* or `error` on the provided observer.
3636
*/
37-
export default class IndefiniteObservable<T> implements Observable<T> {
37+
export class IndefiniteObservable<T> implements Observable<T> {
3838
private _connect: Connect<T>;
3939

4040
/**
@@ -88,3 +88,4 @@ export default class IndefiniteObservable<T> implements Observable<T> {
8888
return this;
8989
}
9090
}
91+
export default IndefiniteObservable;

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@
1717
export * from './types';
1818

1919
export * from './IndefiniteObservable';
20+
export { wrapWithObserver } from './wrapWithObserver';
2021
export { default as IndefiniteObservable } from './IndefiniteObservable';

src/wrapWithObserver.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@ import {
1919
ObserverOrNext,
2020
} from './types';
2121

22-
// TypeScript is a pain to use with polymorphic types unless you wrap them in a
23-
// function that returns a single type. So, that's what this is.
24-
//
25-
// If you give it an observer, you get back that observer. If you give it an
26-
// anonymous function, you get back that anonymous function wrapped in an
27-
// observer.
28-
export default function wrapWithObserver<T>(listener: ObserverOrNext<T>): Observer<T> {
22+
/**
23+
* TypeScript is a pain to use with polymorphic types unless you wrap them in a
24+
* function that returns a single type. So, that's what this is.
25+
*
26+
* If you give it an observer, you get back that observer. If you give it an
27+
* anonymous function, you get back that anonymous function wrapped in an
28+
* observer.
29+
*/
30+
export function wrapWithObserver<T>(listener: ObserverOrNext<T>): Observer<T> {
2931
if (typeof listener === 'function') {
3032
return {
3133
next: listener
@@ -35,3 +37,4 @@ export default function wrapWithObserver<T>(listener: ObserverOrNext<T>): Observ
3537
return listener;
3638
}
3739
}
40+
export default wrapWithObserver;

0 commit comments

Comments
 (0)