Browse Source

feat(core): create DOMInsertionService

pull/3475/head
mehmet-erim 6 years ago
parent
commit
dd5f3572d6
  1. 17
      npm/ng-packs/packages/core/src/lib/services/dom-insertion.service.ts
  2. 1
      npm/ng-packs/packages/core/src/lib/services/index.ts

17
npm/ng-packs/packages/core/src/lib/services/dom-insertion.service.ts

@ -0,0 +1,17 @@
import { Injectable } from '@angular/core';
import { ContentStrategy } from '../strategies/content.strategy';
import { generateHash } from '../utils';
@Injectable({ providedIn: 'root' })
export class DOMInsertionService {
readonly inserted = new Set();
insertElement(contentStrategy: ContentStrategy) {
const hash = generateHash(contentStrategy.content);
if (this.inserted.has(hash)) return;
contentStrategy.insertElement();
this.inserted.add(hash);
}
}

1
npm/ng-packs/packages/core/src/lib/services/index.ts

@ -1,6 +1,7 @@
export * from './application-configuration.service';
export * from './auth.service';
export * from './config-state.service';
export * from './dom-insertion.service';
export * from './lazy-load.service';
export * from './localization.service';
export * from './profile-state.service';

Loading…
Cancel
Save