-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Symbol.observable): is no longer polyfilled (#3387)
BREAKING CHANGE: RxJS will no longer be polyfilling Symbol.observable. That should be done by an actual polyfill library. This is to prevent duplication of code, and also to prevent having modules with side-effects in rxjs.
- Loading branch information
Showing
8 changed files
with
26 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
if (typeof Symbol !== 'function') { | ||
let id = 0; | ||
const symbolFn: any = (description: string) => | ||
`Symbol_${id++} ${description} (RxJS Testing Polyfill)`; | ||
|
||
Symbol = symbolFn; | ||
} | ||
|
||
if (!(Symbol as any).observable) { | ||
(Symbol as any).observable = Symbol('Symbol.observable polyfill from RxJS Testing'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,13 @@ | ||
import { root } from '../util/root'; | ||
|
||
export function getSymbolObservable(context: { Symbol: SymbolConstructor; }): symbol { | ||
let $$observable: symbol; | ||
let Symbol = context.Symbol; | ||
|
||
if (typeof Symbol === 'function') { | ||
if (Symbol.observable) { | ||
$$observable = Symbol.observable; | ||
} else { | ||
$$observable = Symbol('observable'); | ||
Symbol.observable = $$observable; | ||
} | ||
} else { | ||
$$observable = <any>'@@observable'; | ||
} | ||
|
||
return $$observable; | ||
} | ||
|
||
export const observable = getSymbolObservable(root); | ||
|
||
/** | ||
* @deprecated use observable instead | ||
*/ | ||
export const $$observable = observable; | ||
|
||
/** Symbol.observable addition */ | ||
/* Note: This will add Symbol.observable globally for all TypeScript users, | ||
however, we are no longer polyfilling Symbol.observable */ | ||
declare global { | ||
interface SymbolConstructor { | ||
observable: symbol; | ||
} | ||
} | ||
} | ||
|
||
/** Symbol.observable or a string "@@observable". Used for interop */ | ||
export const observable = typeof Symbol === 'function' && Symbol.observable || '@@observable'; |