(config?: BaseConfig)
| 115 | // tslint:enable:variable-name |
| 116 | |
| 117 | protected constructor(config?: BaseConfig) { |
| 118 | super(); |
| 119 | |
| 120 | this.config = {...config}; |
| 121 | |
| 122 | if (this.config.id !== undefined) { |
| 123 | if (!isValidId(this.config.id)) { |
| 124 | throw new TypeError( |
| 125 | `Invalid id provided, expected a non-empty string, got ${String(this.config.id)}` |
| 126 | ); |
| 127 | } |
| 128 | if (Configuration.ENVIRONMENT.checkUniqueId === true) { |
| 129 | const locationId = getLocationId(this); |
| 130 | if ( |
| 131 | UniqueIdsAndLocationIdMap[this.config.id] != null && |
| 132 | UniqueIdsAndLocationIdMap[this.config.id] !== locationId |
| 133 | ) { |
| 134 | throw new TypeError( |
| 135 | `Duplicate id "${this.config.id}" detected by "checkUniqueId" check, consider assigning a unique id.` |
| 136 | ); |
| 137 | } |
| 138 | UniqueIdsAndLocationIdMap[this.config.id] = locationId; |
| 139 | } |
| 140 | } else if ((this.config as UnitConfig<any>).persistent === true) { |
| 141 | throw new TypeError(`An id is required for persistence to work.`); |
| 142 | } |
| 143 | |
| 144 | if (this.config.replay === false) { |
| 145 | this.sourceSubject = this.futureSubject; |
| 146 | (this as any).source = this.future$; |
| 147 | } else { |
| 148 | this.sourceSubject = new BehaviorSubject(undefined); |
| 149 | (this as any).source = this.sourceSubject.asObservable(); |
| 150 | } |
| 151 | |
| 152 | this.setupEvents(); |
| 153 | Object.freeze(this.config); |
| 154 | } |
| 155 | |
| 156 | /** |
| 157 | * Creates a new Observable using the default Observable as source. |
nothing calls this directly
no test coverage detected