* @internal please do not use.
(config?: UnitConfig<T>)
| 224 | * @internal please do not use. |
| 225 | */ |
| 226 | protected constructor(config?: UnitConfig<T>) { |
| 227 | super({ |
| 228 | ...Configuration.UNITS, |
| 229 | ...config, |
| 230 | }); |
| 231 | |
| 232 | const { |
| 233 | cacheSize, |
| 234 | initialValue, |
| 235 | dispatchDebounce, |
| 236 | dispatchDebounceMode, |
| 237 | persistent, |
| 238 | }: UnitConfig<T> = this.config; |
| 239 | |
| 240 | this.cacheSize = isNumber(cacheSize) ? Math.max(1, cacheSize) : 2; // min 1, default 2 |
| 241 | |
| 242 | if (persistent === true) { |
| 243 | this.restoreValueFromPersistentStorage(initialValue); |
| 244 | } else { |
| 245 | this.checkSerializabilityMaybe(initialValue); |
| 246 | this.dispatchInitialValue(this.deepCopyMaybe(initialValue)); |
| 247 | } |
| 248 | |
| 249 | if (dispatchDebounce === true || isNumber(dispatchDebounce)) { |
| 250 | this.dispatchMiddleware = debounce( |
| 251 | this.dispatchMiddleware.bind(this), |
| 252 | dispatchDebounce as number, |
| 253 | dispatchDebounceMode |
| 254 | ); |
| 255 | } |
| 256 | } |
| 257 | |
| 258 | /** |
| 259 | * A helper method that creates a stream by subscribing to the Observable returned by the param `observableProducer` callback. |