1 | /**
|
---|
2 | * @license
|
---|
3 | * Copyright Google LLC All Rights Reserved.
|
---|
4 | *
|
---|
5 | * Use of this source code is governed by an MIT-style license that can be
|
---|
6 | * found in the LICENSE file at https://angular.io/license
|
---|
7 | */
|
---|
8 | import { Optional, SkipSelf, ɵɵdefineInjectable } from '../../di';
|
---|
9 | import { DefaultKeyValueDifferFactory } from './default_keyvalue_differ';
|
---|
10 | export function defaultKeyValueDiffersFactory() {
|
---|
11 | return new KeyValueDiffers([new DefaultKeyValueDifferFactory()]);
|
---|
12 | }
|
---|
13 | /**
|
---|
14 | * A repository of different Map diffing strategies used by NgClass, NgStyle, and others.
|
---|
15 | *
|
---|
16 | * @publicApi
|
---|
17 | */
|
---|
18 | export class KeyValueDiffers {
|
---|
19 | constructor(factories) {
|
---|
20 | this.factories = factories;
|
---|
21 | }
|
---|
22 | static create(factories, parent) {
|
---|
23 | if (parent) {
|
---|
24 | const copied = parent.factories.slice();
|
---|
25 | factories = factories.concat(copied);
|
---|
26 | }
|
---|
27 | return new KeyValueDiffers(factories);
|
---|
28 | }
|
---|
29 | /**
|
---|
30 | * Takes an array of {@link KeyValueDifferFactory} and returns a provider used to extend the
|
---|
31 | * inherited {@link KeyValueDiffers} instance with the provided factories and return a new
|
---|
32 | * {@link KeyValueDiffers} instance.
|
---|
33 | *
|
---|
34 | * @usageNotes
|
---|
35 | * ### Example
|
---|
36 | *
|
---|
37 | * The following example shows how to extend an existing list of factories,
|
---|
38 | * which will only be applied to the injector for this component and its children.
|
---|
39 | * This step is all that's required to make a new {@link KeyValueDiffer} available.
|
---|
40 | *
|
---|
41 | * ```
|
---|
42 | * @Component({
|
---|
43 | * viewProviders: [
|
---|
44 | * KeyValueDiffers.extend([new ImmutableMapDiffer()])
|
---|
45 | * ]
|
---|
46 | * })
|
---|
47 | * ```
|
---|
48 | */
|
---|
49 | static extend(factories) {
|
---|
50 | return {
|
---|
51 | provide: KeyValueDiffers,
|
---|
52 | useFactory: (parent) => {
|
---|
53 | // if parent is null, it means that we are in the root injector and we have just overridden
|
---|
54 | // the default injection mechanism for KeyValueDiffers, in such a case just assume
|
---|
55 | // `defaultKeyValueDiffersFactory`.
|
---|
56 | return KeyValueDiffers.create(factories, parent || defaultKeyValueDiffersFactory());
|
---|
57 | },
|
---|
58 | // Dependency technically isn't optional, but we can provide a better error message this way.
|
---|
59 | deps: [[KeyValueDiffers, new SkipSelf(), new Optional()]]
|
---|
60 | };
|
---|
61 | }
|
---|
62 | find(kv) {
|
---|
63 | const factory = this.factories.find(f => f.supports(kv));
|
---|
64 | if (factory) {
|
---|
65 | return factory;
|
---|
66 | }
|
---|
67 | throw new Error(`Cannot find a differ supporting object '${kv}'`);
|
---|
68 | }
|
---|
69 | }
|
---|
70 | /** @nocollapse */
|
---|
71 | KeyValueDiffers.ɵprov = ɵɵdefineInjectable({ token: KeyValueDiffers, providedIn: 'root', factory: defaultKeyValueDiffersFactory });
|
---|
72 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoia2V5dmFsdWVfZGlmZmVycy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uLy4uL3BhY2thZ2VzL2NvcmUvc3JjL2NoYW5nZV9kZXRlY3Rpb24vZGlmZmVycy9rZXl2YWx1ZV9kaWZmZXJzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7R0FNRztBQUVILE9BQU8sRUFBQyxRQUFRLEVBQUUsUUFBUSxFQUFrQixrQkFBa0IsRUFBQyxNQUFNLFVBQVUsQ0FBQztBQUNoRixPQUFPLEVBQUMsNEJBQTRCLEVBQUMsTUFBTSwyQkFBMkIsQ0FBQztBQXdHdkUsTUFBTSxVQUFVLDZCQUE2QjtJQUMzQyxPQUFPLElBQUksZUFBZSxDQUFDLENBQUMsSUFBSSw0QkFBNEIsRUFBRSxDQUFDLENBQUMsQ0FBQztBQUNuRSxDQ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