fix(platform-server): allow multiple instances of platformServer and platformDynamicServer
This commit is contained in:

committed by
Igor Minar

parent
0e2fd9d91a
commit
17486fd696
@ -23,3 +23,6 @@ export type DebugDomRootRenderer = typeof r._DebugDomRootRenderer;
|
||||
export const DebugDomRootRenderer: typeof r.DebugDomRootRenderer = r.DebugDomRootRenderer;
|
||||
export type DebugDomRendererV2 = typeof r._DebugDomRendererV2;
|
||||
export const DebugDomRendererV2: typeof r.DebugDomRendererV2 = r.DebugDomRendererV2;
|
||||
export type ALLOW_MULTIPLE_PLATFORMS = typeof r.ALLOW_MULTIPLE_PLATFORMS;
|
||||
export const ALLOW_MULTIPLE_PLATFORMS: typeof r.ALLOW_MULTIPLE_PLATFORMS =
|
||||
r.ALLOW_MULTIPLE_PLATFORMS;
|
||||
|
@ -14,7 +14,7 @@ import {BrowserModule, DOCUMENT} from '@angular/platform-browser';
|
||||
import {ServerPlatformLocation} from './location';
|
||||
import {Parse5DomAdapter, parseDocument} from './parse5_adapter';
|
||||
import {PlatformState} from './platform_state';
|
||||
import {DebugDomRendererV2, DebugDomRootRenderer} from './private_import_core';
|
||||
import {ALLOW_MULTIPLE_PLATFORMS, DebugDomRendererV2, DebugDomRootRenderer} from './private_import_core';
|
||||
import {SharedStylesHost, getDOM} from './private_import_platform-browser';
|
||||
import {ServerRendererV2, ServerRootRenderer} from './server_renderer';
|
||||
|
||||
@ -25,8 +25,9 @@ function notSupported(feature: string): Error {
|
||||
export const INTERNAL_SERVER_PLATFORM_PROVIDERS: Array<any /*Type | Provider | any[]*/> = [
|
||||
{provide: DOCUMENT, useFactory: _document, deps: [Injector]},
|
||||
{provide: PLATFORM_INITIALIZER, useFactory: initParse5Adapter, multi: true, deps: [Injector]},
|
||||
{provide: PlatformLocation, useClass: ServerPlatformLocation},
|
||||
PlatformState,
|
||||
{provide: PlatformLocation, useClass: ServerPlatformLocation}, PlatformState,
|
||||
// Add special provider that allows multiple instances of platformServer* to be created.
|
||||
{provide: ALLOW_MULTIPLE_PLATFORMS, useValue: true}
|
||||
];
|
||||
|
||||
function initParse5Adapter(injector: Injector) {
|
||||
|
@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {ApplicationRef, NgModuleFactory, NgModuleRef, PlatformRef, Provider, Type, destroyPlatform} from '@angular/core';
|
||||
import {ApplicationRef, NgModuleFactory, NgModuleRef, PlatformRef, Provider, Type} from '@angular/core';
|
||||
import {filter} from 'rxjs/operator/filter';
|
||||
import {first} from 'rxjs/operator/first';
|
||||
import {toPromise} from 'rxjs/operator/toPromise';
|
||||
@ -40,7 +40,7 @@ function _render<T>(
|
||||
.call(first.call(filter.call(applicationRef.isStable, (isStable: boolean) => isStable)))
|
||||
.then(() => {
|
||||
const output = platform.injector.get(PlatformState).renderToString();
|
||||
destroyPlatform();
|
||||
platform.destroy();
|
||||
return output;
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user