Socket
Socket
Sign inDemoInstall

@rx-signals/store

Package Overview
Dependencies
Maintainers
1
Versions
94
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rx-signals/store - npm Package Compare versions

Comparing version 3.0.0-rc23 to 3.0.0-rc24

3

dist/cjs/context-handle.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ContextHandle = void 0;
/**
* @internal
*/
class ContextHandle {

@@ -5,0 +8,0 @@ constructor() {

10

dist/cjs/controlled-subject.js

@@ -6,5 +6,9 @@ "use strict";

const rxjs_1 = require("rxjs");
const operators_1 = require("rxjs/operators");
const context_handle_1 = require("./context-handle");
const store_utils_1 = require("./store-utils");
/**
* Used by the {@link Store}
*
* @internal
*/
class ControlledSubject {

@@ -148,4 +152,4 @@ constructor(id, isBehavior, onSourceError, onSourceCompleted, delayedEventQueue) {

this.pipe = this.isBehavior
? this.subject.pipe((0, operators_1.filter)(value => value !== store_utils_1.NO_VALUE), (0, operators_1.distinctUntilChanged)())
: this.delayedEventQueue.getQueueDelayedObservable(this.subject).pipe((0, operators_1.share)());
? this.subject.pipe((0, rxjs_1.filter)(value => value !== store_utils_1.NO_VALUE), (0, rxjs_1.distinctUntilChanged)())
: this.delayedEventQueue.getQueueDelayedObservable(this.subject).pipe((0, rxjs_1.share)());
localSources.forEach(source => {

@@ -152,0 +156,0 @@ this.addSource(source);

@@ -5,3 +5,7 @@ "use strict";

const rxjs_1 = require("rxjs");
const operators_1 = require("rxjs/operators");
/**
* Used by the {@link Store}
*
* @internal
*/
class DelayedEventQueue {

@@ -12,3 +16,3 @@ constructor() {

getQueueDelayedObservable(observable) {
return observable.pipe((0, operators_1.mergeMap)(value => this.fromDelayedQueue().pipe((0, operators_1.map)(() => value))));
return observable.pipe((0, rxjs_1.mergeMap)(value => this.fromDelayedQueue().pipe((0, rxjs_1.map)(() => value))));
}

@@ -15,0 +19,0 @@ fromDelayedQueue() {

@@ -5,3 +5,2 @@ "use strict";

const rxjs_1 = require("rxjs");
const operators_1 = require("rxjs/operators");
const signals_factory_1 = require("./signals-factory");

@@ -22,3 +21,3 @@ const store_utils_1 = require("./store-utils");

const effectId = (0, store_utils_1.getEffectId)();
const internalResultEffect = (input, store, previousInput, previousResult) => store.getEffect(effectId).pipe((0, operators_1.take)(1), (0, operators_1.switchMap)(effect => {
const internalResultEffect = (input, store, previousInput, previousResult) => store.getEffect(effectId).pipe((0, rxjs_1.take)(1), (0, rxjs_1.switchMap)(effect => {
try {

@@ -28,3 +27,3 @@ const wrappedEffect = config.wrappedEffectGetter

: effect;
return wrappedEffect(input, store, previousInput, previousResult).pipe((0, operators_1.take)(1));
return wrappedEffect(input, store, previousInput, previousResult).pipe((0, rxjs_1.take)(1));
}

@@ -57,3 +56,3 @@ catch (error) {

// It is important to setup the combined observable as behavior,
// because a simple shareReplay (even with refCount) would create a memory leak!!!
// because a simple shareReplay (even with refCount) could create a memory leak!!!
const combinedId = (0, store_utils_1.getDerivedId)();

@@ -69,11 +68,11 @@ store.addDerivedState(combinedId, (0, rxjs_1.combineLatest)([

? combined
: combined.pipe((0, operators_1.debounceTime)(config.effectDebounceTime));
store.add4TypedEventSource(resultEvent, triggeredInputEvent, outIds.errors, outIds.successes, eventSourceInput.pipe((0, operators_1.filter)(([input, resultState, token]) => token !== resultState.resultToken ||
: combined.pipe((0, rxjs_1.debounceTime)(config.effectDebounceTime));
store.add4TypedEventSource(resultEvent, triggeredInputEvent, outIds.errors, outIds.successes, eventSourceInput.pipe((0, rxjs_1.filter)(([input, resultState, token]) => token !== resultState.resultToken ||
resultState.resultInput === undefined ||
!effectInputEquals(input, resultState.resultInput)), (0, operators_1.switchMap)(([input, resultState, token, triggeredInput]) => config.withTrigger && input !== triggeredInput
? store.getEventStream(inIds.trigger).pipe((0, operators_1.map)(() => ({
!effectInputEquals(input, resultState.resultInput)), (0, rxjs_1.switchMap)(([input, resultState, token, triggeredInput]) => config.withTrigger && input !== triggeredInput
? store.getEventStream(inIds.trigger).pipe((0, rxjs_1.map)(() => ({
type: triggeredInputEvent,
event: input,
})))
: internalResultEffect(input, store, resultState.resultInput, resultState.result).pipe((0, operators_1.switchMap)(result => (0, rxjs_1.of)({
: internalResultEffect(input, store, resultState.resultInput, resultState.result).pipe((0, rxjs_1.switchMap)(result => (0, rxjs_1.of)({
type: resultEvent,

@@ -93,3 +92,3 @@ event: {

},
})), (0, operators_1.catchError)(error => (0, rxjs_1.of)({
})), (0, rxjs_1.catchError)(error => (0, rxjs_1.of)({
type: outIds.errors,

@@ -107,3 +106,3 @@ event: {

}))))), resultEvent);
store.addDerivedState(outIds.combined, combined.pipe((0, operators_1.map)(([input, resultState, token, triggeredInput]) => ({
store.addDerivedState(outIds.combined, combined.pipe((0, rxjs_1.map)(([input, resultState, token, triggeredInput]) => ({
currentInput: input,

@@ -137,3 +136,3 @@ result: resultState.result,

/**
* This function creates an EffectSignalsFactory<Input, Result>.
* This function creates an {@link EffectSignalsFactory}.
*

@@ -140,0 +139,0 @@ * @template Input - specifies the input type for the effect

@@ -17,2 +17,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.getSequence = exports.expectSequence = void 0;
__exportStar(require("./effect-signals-factory"), exports);

@@ -23,3 +24,7 @@ __exportStar(require("./model-signals-factory"), exports);

__exportStar(require("./store-utils"), exports);
var test_utils_1 = require("./test-utils/test-utils");
Object.defineProperty(exports, "expectSequence", { enumerable: true, get: function () { return test_utils_1.expectSequence; } });
Object.defineProperty(exports, "getSequence", { enumerable: true, get: function () { return test_utils_1.getSequence; } });
__exportStar(require("./type-utils"), exports);
__exportStar(require("./validated-input-with-result-signals-factory"), exports);
//# sourceMappingURL=index.js.map

@@ -31,3 +31,3 @@ "use strict";

/**
* This function creates a ModelSignalsFactory<T>.
* This function creates a {@link ModelSignalsFactory}.
*

@@ -34,0 +34,0 @@ * @template T - specifies the type of the model

@@ -20,3 +20,3 @@ "use strict";

/**
* The SignalsFactory wraps a SignalsBuild<IN, OUT, CONFIG, EFF> function, allowing for simple Signals composition
* A SignalsFactory wraps a {@link SignalsBuild} function, allowing for simple {@link Signals} composition
* and manipulation.

@@ -27,12 +27,12 @@ * Via the compose method, two SignalsFactories can be easily composed to a new one.

* compose, extendSetup, mapInput, mapOutput and mapConfig).
* SignalsFactory instances are immutable, hence all methods return a new SignalsFactory instance.
* SignalsFactory instances are immutable (persistent data structures), hence all methods return a new SignalsFactory instance.
* (The whole purpose of this class is to provide immutable SignalsBuild composition)
*
* @class SignalsFactory<IN extends NameToSignalId, OUT extends NameToSignalId, CONFIG extends Configuration = {}, EFF extends NameToEffectId = {}>
* @class SignalsFactory
*/
class SignalsFactory {
/**
* The constructor takes a pure function implementing SignalsBuild<IN, OUT, CONFIG, EFF>.
* The constructor takes a pure function implementing SignalsBuild.
*
* @param {SignalsBuild<IN, OUT, CONFIG, EFF>} build - a pure function mapping from CONFIG to Signals<IN, OUT, EFF>
* @param {SignalsBuild<IN, OUT, CONFIG, EFF>} build - a pure function mapping from CONFIG to Signals
* @constructor

@@ -44,9 +44,9 @@ */

/**
* The compose method takes a second SignalsFactory<IN2, OUT2, CONFIG2, EFF2> and returns a new SignalsFactory
* that represents the composition of this SignalsFactory and the argument SignalsFactory<IN2, OUT2, CONFIG2, EFF2>.
* You can re-map the input, output, configuration and effects of the resulting ComposedFactory<IN, OUT, CONFIG, EFF, IN2, OUT2, CONFIG2, EFF2>
* The compose method takes a second SignalsFactory2 and returns a new SignalsFactory
* that represents the composition of this SignalsFactory and the argument SignalsFactory2.
* You can re-map the input, output, configuration and effects of the resulting composed SignalsFactory
* by using mapInput, mapOutput, mapConfig and mapEffects correspondingly (as well as the many other convenience methods).
*
* @param {SignalsFactory<IN2, OUT2, CONFIG2, EFF2>} factory2 - a SignalsFactory<IN2, OUT2, CONFIG2, EFF2>
* @returns {ComposedFactory<IN, OUT, CONFIG, EFF, IN2, OUT2, CONFIG2, EFF2>} - the SignalsFactory resulting from the composition of SignalsFactory<IN, OUT, CONFIG, EFF> and SignalsFactory<IN2, OUT2, CONFIG2, EFF2>
* @param {SignalsFactory} factory2 - a SignalsFactory
* @returns {SignalsFactory} - the SignalsFactory resulting from the composition of this SignalsFactory and SignalsFactory2
*/

@@ -72,9 +72,9 @@ compose(factory2) {

* This method implements monadic-bind for the SignalsFactory.
* It takes as argument a pure function that implements SignalsMapToFactory<IN, OUT, CONFIG, EFF, IN2, OUT2, CONFIG2, EFF2>, hence
* a function taking SignalsBuild<IN, OUT, CONFIG, EFF> as argument and returning a SignalsFactory<IN2, OUT2, CONFIG2, EFF2>.
* The result of bind is a new SignalsFactory<IN2, OUT2, CONFIG2, EFF2> that uses the SignalsBuild<IN2, OUT2, CONFIG2, EFF2>::build
* It takes as argument a pure function that implements SignalsMapToFactory\<IN, OUT, CONFIG, EFF, IN2, OUT2, CONFIG2, EFF2\>, hence
* a function taking SignalsBuild\<IN, OUT, CONFIG, EFF\> as argument and returning a SignalsFactory\<IN2, OUT2, CONFIG2, EFF2\>.
* The result of bind is a new SignalsFactory that uses the SignalsBuild\<IN2, OUT2, CONFIG2, EFF2\>::build
* of the factory returned from the mapper (hence the result of bind is not the same instance as returned by the mapper).
*
* @param {BindMapper<IN, OUT, CONFIG, EFF, IN2, OUT2, CONFIG2, EFF2>} mapper - a pure function mapping from SignalsBuild<IN, OUT, CONFIG, EFF> to SignalsFactory<IN2, OUT2, CONFIG2, EFF2>
* @returns {SignalsFactory<IN2, OUT2, CONFIG2, EFF>} - a new SignalsFactory<IN2, OUT2, CONFIG2, EFF2>
* @param {BindMapper} mapper - a pure function mapping from SignalsBuild\<IN, OUT, CONFIG, EFF\> to SignalsFactory\<IN2, OUT2, CONFIG2, EFF2\>
* @returns {SignalsFactory} - a new SignalsFactory\<IN2, OUT2, CONFIG2, EFF2\>
*/

@@ -87,9 +87,9 @@ bind(mapper) {

* This method implements the functor-fmap for the SignalsFactory.
* It takes as argument a pure function that implements BuildMapper<IN, OUT, CONFIG, EFF, IN2, OUT2, CONFIG2, EFF2>, hence
* a function taking SignalsBuild<IN, OUT, CONFIG, EFF> as argument and returning a SignalsBuild<IN2, OUT2, CONFIG2, EFF2>.
* The result of fmap is a new SignalsFactory<IN2, OUT2, CONFIG2, EFF2> that uses the SignalsBuild<IN2, OUT2, CONFIG2, EFF2> returned
* It takes as argument a pure function that implements BuildMapper\<IN, OUT, CONFIG, EFF, IN2, OUT2, CONFIG2, EFF2\>, hence
* a function taking SignalsBuild\<IN, OUT, CONFIG, EFF\> as argument and returning a SignalsBuild\<IN2, OUT2, CONFIG2, EFF2\>.
* The result of fmap is a new SignalsFactory that uses the SignalsBuild\<IN2, OUT2, CONFIG2, EFF2\> returned
* from the mapper.
*
* @param {BuildMapper<IN, OUT, CONFIG, EFF, IN2, OUT2, CONFIG2, EFF2>} mapper - a pure function mapping from SignalsBuild<IN, OUT, CONFIG, EFF> to SignalsBuild<IN2, OUT2, CONFIG2, EFF2>
* @returns {SignalsFactory<IN2, OUT2, CONFIG2, EFF2>} - a new SignalsFactory<IN2, OUT2, CONFIG2, EFF2>
* @param {BuildMapper} mapper - a pure function mapping from SignalsBuild\<IN, OUT, CONFIG, EFF\> to SignalsBuild\<IN2, OUT2, CONFIG2, EFF2\>
* @returns {SignalsFactory} - a new SignalsFactory\<IN2, OUT2, CONFIG2, EFF2\>
*/

@@ -101,8 +101,8 @@ fmap(mapper) {

/**
* The extendSetup method takes as argument a function that implements ExtendSetup<IN, OUT, CONFIG, EFF>.
* The extendSetup method takes as argument a function that implements ExtendSetup\<IN, OUT, CONFIG, EFF\>.
* It returns a new SignalsFactory of the same type as this SignalsFactory, but with a wrapped SignalsBuild that
* extends the code executed in the Signals setup method by the provided code.
*
* @param {ExtendSetup<IN, OUT, CONFIG, EFF>} extend - a function extending the setup method of the Signals produced by the SignalsBuild of the resulting SignalsFactory
* @returns {SignalsFactory<IN, OUT, CONFIG, EFF>} - a new SignalsFactory with extended store setup
* @param {ExtendSetup} extend - a function extending the setup method of the Signals produced by the SignalsBuild of the resulting SignalsFactory
* @returns {SignalsFactory} - a new SignalsFactory with extended store setup
*/

@@ -122,13 +122,13 @@ extendSetup(extend) {

* If keepInputId is set to true, it returns a new SignalsFactory of the same type as this SignalsFactory,
* but with an extended setup logic, that connects the Signal<S extends T> that corresponds to the named output-id to a
* new Signal<T> corresponding to the named input-id.
* but with an extended setup logic, that connects the Signal\<S extends T\> that corresponds to the named output-id to a
* new Signal\<T\> corresponding to the named input-id.
* If keepInputId is set to false, it also extends the setup logic to connect the corresponding signal-ids, but in addition
* the specified input-id will be excluded from the IN-type of the resulting factory.
* (also see store.connect documentation, as this is used under the hood)
* Typescript will enforce that both names (keys) map to compatible signal ids, hence if KIN corresponds to SignalId<T>,
* then KOUT must correspond to SignalId<S extends T> (though one might be an EventId and the other a BehaviorId).
* Typescript will enforce that both names (keys) map to compatible signal ids, hence if KIN corresponds to SignalId\<T\>,
* then KOUT must correspond to SignalId\<S extends T\> (though one might be an EventId and the other a BehaviorId).
* That is, even though you only use strings as arguments, this method is still type-safe and will not compile if you try to specify names of non-existing or incompatible ids.
*
* @param {KIN} inputName - a key of IN, where IN[toName] must be of type Signal<T>
* @param {KOUT} outputName - a key of OUT, where OUT[outputName] must be of type Signal<S extends T>
* @param {KIN} inputName - a key of IN, where IN\[toName\] must be of type Signal\<T\>
* @param {KOUT} outputName - a key of OUT, where OUT\[outputName\] must be of type Signal\<S extends T\>
* @param {boolean} keepInputId - if set to false, the input-id corresponding to toName will be removed from the resulting factories' IN

@@ -151,4 +151,4 @@ * @returns {SignalsFactory} - a new SignalsFactory with the concrete type depending on the keepInputId argument

*
* @param {KIN} inputName - a key of IN, where IN[toName] must be of type Signal<T>
* @param {ID} fromId - a Signal<S extends T>
* @param {KIN} inputName - a key of IN, where IN\[toName\] must be of type Signal\<T\>
* @param {ID} fromId - a Signal\<S extends T\>
* @param {boolean} keepInputId - if set to false, the input-id corresponding to toName will be removed from the resulting factories' IN

@@ -170,4 +170,4 @@ * @returns {SignalsFactory} - a new SignalsFactory with the concrete type depending on the keepInputId argument

*
* @param {KIN} inputName - a key of IN, where IN[toName] must be of type Signal<T>
* @param {function} sourceGetter - a function returning an Observable<S extends T>
* @param {KIN} inputName - a key of IN, where IN\[toName\] must be of type Signal\<T\>
* @param {function} sourceGetter - a function returning an Observable\<S extends T\>
* @param {boolean} keepInputId - if set to false, the input-id corresponding to toName will be removed from the resulting factories' IN

@@ -185,7 +185,7 @@ * @returns {SignalsFactory} - a new SignalsFactory with the concrete type depending on the keepInputId argument

/**
* The mapConfig method takes as argument a pure function that implements MapConfig<CONFIG, CONFIG2>.
* It returns a new SignalsFactory<IN, OUT, CONFIG2, EFF>.
* The mapConfig method takes as argument a pure function that implements MapConfig\<CONFIG, CONFIG2\>.
* It returns a new SignalsFactory\<IN, OUT, CONFIG2, EFF\>.
*
* @param {MapConfig<CONFIG, CONFIG2>} mapper - a pure function mapping CONFIG2 to CONFIG
* @returns {SignalsFactory<IN, OUT, CONFIG2, EFF>} - a new SignalsFactory with different Configuration type
* @param {MapConfig} mapper - a pure function mapping CONFIG2 to CONFIG
* @returns {SignalsFactory} - a new SignalsFactory with different Configuration type
*/

@@ -197,7 +197,7 @@ mapConfig(mapper) {

/**
* The mapInput method takes as argument a pure function that implements MapSignalIds<IN, IN2>.
* It returns a new SignalsFactory<IN2, OUT, CONFIG, EFF>.
* The mapInput method takes as argument a pure function that implements MapSignalIds\<IN, IN2\>.
* It returns a new SignalsFactory\<IN2, OUT, CONFIG, EFF\>.
*
* @param {MapSignalIds<IN, IN2, CONFIG>} mapper - a pure function mapping from IN to IN2
* @returns {SignalsFactory<IN2, OUT, CONFIG, EFF>} - a new SignalsFactory with different input signals
* @param {MapSignalIds} mapper - a pure function mapping from IN to IN2
* @returns {SignalsFactory} - a new SignalsFactory with different input signals
*/

@@ -217,4 +217,4 @@ mapInput(mapper) {

* @param {K} name - the name of the new SignalId
* @param {() => ID} idGetter - a function returning the new SignalId
* @returns {SignalsFactory<AddSignalId<IN, K, ID>, OUT, CONFIG, EFF>} - a new SignalsFactory with modified input signals
* @param {function} idGetter - a function returning the new SignalId
* @returns {SignalsFactory} - a new SignalsFactory with modified input signals
*/

@@ -229,6 +229,6 @@ addInputId(name, idGetter) {

* @template K1 - a concrete key of IN
* @template K2 - the new name for IN[K1]
* @template K2 - the new name for IN\[K1\]
* @param {K1} oldName - the old key
* @param {K2} newName - the new key
* @returns {SignalsFactory<RenameId<IN, K1, K2>, OUT, CONFIG, EFF>} - a new SignalsFactory with modified input signals
* @returns {SignalsFactory} - a new SignalsFactory with modified input signals
*/

@@ -248,3 +248,3 @@ renameInputId(oldName, newName) {

* @param {K} name - the name of the SignalId to be removed
* @returns {SignalsFactory<Omit<IN, K>, OUT, CONFIG, EFF>} - a new SignalsFactory with modified input signals
* @returns {SignalsFactory} - a new SignalsFactory with modified input signals
*/

@@ -259,7 +259,7 @@ removeInputId(name) {

/**
* The mapOutput method takes as argument a pure function that implements MapSignalIds<OUT, OUT2>.
* It returns a new SignalsFactory<IN, OUT2, CONFIG, EFF>.
* The mapOutput method takes as argument a pure function that implements MapSignalIds\<OUT, OUT2\>.
* It returns a new SignalsFactory\<IN, OUT2, CONFIG, EFF\>.
*
* @param {MapSignalIds<OUT, OUT2>} mapper - a pure function mapping from OUT to OUT2
* @returns {SignalsFactory<IN, OUT2, CONFIG, EFF>} - a new SignalsFactory with different output signals
* @param {MapSignalIds} mapper - a pure function mapping from OUT to OUT2
* @returns {SignalsFactory} - a new SignalsFactory with different output signals
*/

@@ -279,4 +279,4 @@ mapOutput(mapper) {

* @param {K} name - the name of the new SignalId
* @param {() => ID} idGetter - a function returning the new SignalId
* @returns {SignalsFactory<IN, AddOrReplaceId<OUT, K, ID>, CONFIG, EFF>} - a new SignalsFactory with modified output signals
* @param {function} idGetter - a function returning the new SignalId
* @returns {SignalsFactory} - a new SignalsFactory with modified output signals
*/

@@ -291,6 +291,6 @@ addOutputId(name, idGetter) {

* @template K1 - a concrete key of OUT
* @template K2 - the new name for OUT[K1]
* @template K2 - the new name for OUT\[K1\]
* @param {K1} oldName - the old key
* @param {K2} newName - the new key
* @returns {SignalsFactory<IN, RenameId<OUT, K1, K2>, CONFIG, EFF>} - a new SignalsFactory with modified output signals
* @returns {SignalsFactory} - a new SignalsFactory with modified output signals
*/

@@ -310,3 +310,3 @@ renameOutputId(oldName, newName) {

* @param {K} name - the name of the SignalId to be removed
* @returns {SignalsFactory<IN, Omit<OUT, K>, CONFIG, EFF>} - a new SignalsFactory with modified output signals
* @returns {SignalsFactory} - a new SignalsFactory with modified output signals
*/

@@ -325,10 +325,10 @@ removeOutputId(name) {

* new behavior into output under the removed name of the existing behavior.
* Hence, this transforms from SignalsFactory<IN, OUT, CONFIG> to SignalsFactory<IN, OUT2, CONFIG>
* with OUT2 having the same keys as OUT, but OUT2[KOUT] having type TNEW and OUT[KOUT] having type TOLD
* Hence, this transforms from SignalsFactory\<IN, OUT, CONFIG\> to SignalsFactory\<IN, OUT2, CONFIG\>
* with OUT2 having the same keys as OUT, but OUT2\[KOUT\] having type TNEW and OUT\[KOUT\] having type TOLD
*
* @template KOUT - a concrete output key mapping to a BehaviorId<any>
* @template TNEW - value-type of the OUT2[KOUT] BehaviorId after mapping
* @param {KOUT} outputName - the name of a BehaviorId<any> from OUT
* @param {function} mapper - a function returning Observable<TNEW>
* @returns {SignalsFactory<IN, AddOrReplaceId<OUT, KOUT, BehaviorId<TNEW>>, CONFIG, EFF>} - a new SignalsFactory with a modified output signal
* @template TNEW - value-type of the OUT2\[KOUT\] BehaviorId after mapping
* @param {KOUT} outputName - the name of a BehaviorId\<any\> from OUT
* @param {function} mapper - a function returning Observable\<TNEW\>
* @returns {SignalsFactory} - a new SignalsFactory with a modified output signal
*/

@@ -347,7 +347,7 @@ mapOutputBehavior(outputName, mapper) {

/**
* The mapEffects method takes as argument a pure function that implements MapEffectIds<EFF, EFF2, CONFIG>.
* It returns a new SignalsFactory<IN, OUT, CONFIG, EFF2>.
* The mapEffects method takes as argument a pure function that implements MapEffectIds\<EFF, EFF2, CONFIG\>.
* It returns a new SignalsFactory\<IN, OUT, CONFIG, EFF2\>.
*
* @param {MapSignalIds<EFF, EFF2>} mapper - a pure function mapping from EFF to EFF2
* @returns {SignalsFactory<IN, OUT, CONFIG, EFF2>} - a new SignalsFactory with different effect-ids
* @param {MapSignalIds} mapper - a pure function mapping from EFF to EFF2
* @returns {SignalsFactory} - a new SignalsFactory with different effect-ids
*/

@@ -367,4 +367,4 @@ mapEffects(mapper) {

* @param {K} name - the name of the new EffectId
* @param {() => ID} idGetter - a function returning the new EffectId
* @returns {SignalsFactory<IN, OUT, CONFIG, AddEffectId<EFF, K, ID>>} - a new SignalsFactory with modified effect-ids
* @param {function} idGetter - a function returning the new EffectId
* @returns {SignalsFactory} - a new SignalsFactory with modified effect-ids
*/

@@ -380,3 +380,3 @@ addEffectId(name, idGetter) {

* @param {K} name - the name of in NameToEffectIds to be removed
* @returns {SignalsFactory<IN, OUT, CONFIG, Omit<EFF, K>>} - a new SignalsFactory with modified effect-ids
* @returns {SignalsFactory} - a new SignalsFactory with modified effect-ids
*/

@@ -419,3 +419,3 @@ removeEffectId(name) {

* @param {K2} newName - the new key
* @returns {SignalsFactory<IN, OUT, CONFIG, RenameEffectId<EFF, K1, K2>>} - a new SignalsFactory with modified effect-ids
* @returns {SignalsFactory} - a new SignalsFactory with modified effect-ids
*/

@@ -422,0 +422,0 @@ renameEffectId(oldName, newName) {

@@ -5,2 +5,5 @@ "use strict";

const store_utils_1 = require("./store-utils");
/**
* @internal
*/
class SourceObservable {

@@ -7,0 +10,0 @@ constructor(sourceId, sourceObservable, lazySubscription, initialValueOrValueGetter = store_utils_1.NO_VALUE) {

@@ -11,4 +11,4 @@ "use strict";

*
* @template T - specifies the type for the corresponding behavior
* @param {string} nameExtension - an optional extension to the symbol name (so the string representation). Usually, you don't need this, cause even for debugging purposes, you should use store.setIdName/getIdName.
* @template T - specifies the value-type for the corresponding behavior
* @param {string} nameExtension - an optional extension to the symbol name (so the string representation). Usually, you don't need this, cause even for debugging purposes, you should use {@link Store.setIdName} and {@link Store.getIdName}.
* @returns {StateId<T>}

@@ -21,4 +21,4 @@ */

*
* @template T - specifies the type for the corresponding behavior
* @param {string} nameExtension - an optional extension to the symbol name (so the string representation). Usually, you don't need this, cause even for debugging purposes, you should use store.setIdName/getIdName.
* @template T - specifies the value-type for the corresponding behavior
* @param {string} nameExtension - an optional extension to the symbol name (so the string representation). Usually, you don't need this, cause even for debugging purposes, you should use {@link Store.setIdName} and {@link Store.getIdName}.
* @returns {DerivedId<T>}

@@ -31,4 +31,4 @@ */

*
* @template T - specifies the type for the corresponding event
* @param {string} nameExtension - an optional extension to the symbol name (so the string representation). Usually, you don't need this, cause even for debugging purposes, you should use store.setIdName/getIdName.
* @template T - specifies the value-type for the corresponding event
* @param {string} nameExtension - an optional extension to the symbol name (so the string representation). Usually, you don't need this, cause even for debugging purposes, you should use {@link Store.setIdName} and {@link Store.getIdName}.
* @returns {EventId<T>}

@@ -35,0 +35,0 @@ */

@@ -5,3 +5,2 @@ "use strict";

const rxjs_1 = require("rxjs");
const operators_1 = require("rxjs/operators");
const controlled_subject_1 = require("./controlled-subject");

@@ -12,4 +11,4 @@ const delayed_event_queue_1 = require("./delayed-event-queue");

/**
* The rx-signals Store provides RxJs-Observables for RP (reactive programming) BehaviorStreams
* and EventStreams (behaviors and events are the two different types of signals, where behaviors represent state).
* The rx-signals Store provides RxJs-Observables for RP (reactive programming) - BehaviorStreams
* and EventStreams (behaviors and events are the two different types of signals, where behaviors represent immutable state).
* The Store separates the sources of these streams from the streams itself.

@@ -137,3 +136,3 @@ *

addReducer(stateIdentifier, eventIdentifier, reducer) {
const sourceObservable = this.getEventStream(eventIdentifier).pipe((0, operators_1.withLatestFrom)(this.getBehavior(stateIdentifier)), (0, operators_1.map)(([event, state]) => reducer(state, event)));
const sourceObservable = this.getEventStream(eventIdentifier).pipe((0, rxjs_1.withLatestFrom)(this.getBehavior(stateIdentifier)), (0, rxjs_1.map)(([event, state]) => reducer(state, event)));
this.getBehaviorControlledSubject(stateIdentifier).addSource(new source_observable_1.SourceObservable(eventIdentifier, sourceObservable, false));

@@ -247,3 +246,3 @@ }

* This method takes a callback that performs Store operations.
* It returns a LifecycleHandle that can be used to reset or end the lifecycle of signals
* It returns a {@link LifecycleHandle} that can be used to reset or end the lifecycle of signals
* and signal-sources that are added to the store during the callback execution.

@@ -316,3 +315,3 @@ *

.asObservable()
.pipe((0, operators_1.switchMap)(s => {
.pipe((0, rxjs_1.switchMap)(s => {
var _a, _b;

@@ -330,4 +329,2 @@ return ((_b = (_a = s.get(identifier)) === null || _a === void 0 ? void 0 : _a.getNumberOfSources()) !== null && _b !== void 0 ? _b : 0) > 0

* Technically, this is done by first removing all sources and then adding them again.
*
* @returns {void} - the behavior observable (shared and distinct)
*/

@@ -342,5 +339,3 @@ resetBehaviors() {

if (controlledSubject.isObservableSubscribed()) {
const result = this.getEventStream(identifier)
.pipe((0, operators_1.filter)(val => val === event), (0, operators_1.take)(1), (0, operators_1.map)(() => true), (0, operators_1.delay)(1, rxjs_1.asyncScheduler))
.toPromise();
const result = (0, rxjs_1.firstValueFrom)(this.getEventStream(identifier).pipe((0, rxjs_1.filter)(val => val === event), (0, rxjs_1.take)(1), (0, rxjs_1.map)(() => true), (0, rxjs_1.delay)(1, rxjs_1.asyncScheduler)));
controlledSubject.next(event);

@@ -352,3 +347,3 @@ return result;

/**
* This method adds an event source to the Store. There can be multiple sources
* This method adds an event source to the store. There can be multiple sources
* for the same event type. However, each source must be identified by its own

@@ -389,3 +384,3 @@ * symbol and adding two sources with the same symbol would result in an error.

const sourceId = Symbol('');
const sharedSource = this.getDependentObservable(observable.pipe((0, operators_1.delay)(1, rxjs_1.asyncScheduler), (0, operators_1.share)()), subscribeObservableOnlyIfEventIsSubscribed);
const sharedSource = this.getDependentObservable(observable.pipe((0, rxjs_1.delay)(1, rxjs_1.asyncScheduler), (0, rxjs_1.share)()), subscribeObservableOnlyIfEventIsSubscribed);
this.addTypedEventSource(sourceId, eventIdentifierA, sharedSource);

@@ -410,3 +405,3 @@ this.addTypedEventSource(sourceId, eventIdentifierB, sharedSource);

const sourceId = Symbol('');
const sharedSource = this.getDependentObservable(observable.pipe((0, operators_1.delay)(1, rxjs_1.asyncScheduler), (0, operators_1.share)()), subscribeObservableOnlyIfEventIsSubscribed);
const sharedSource = this.getDependentObservable(observable.pipe((0, rxjs_1.delay)(1, rxjs_1.asyncScheduler), (0, rxjs_1.share)()), subscribeObservableOnlyIfEventIsSubscribed);
this.addTypedEventSource(sourceId, eventIdentifierA, sharedSource);

@@ -433,3 +428,3 @@ this.addTypedEventSource(sourceId, eventIdentifierB, sharedSource);

const sourceId = Symbol('');
const sharedSource = this.getDependentObservable(observable.pipe((0, operators_1.delay)(1, rxjs_1.asyncScheduler), (0, operators_1.share)()), subscribeObservableOnlyIfEventIsSubscribed);
const sharedSource = this.getDependentObservable(observable.pipe((0, rxjs_1.delay)(1, rxjs_1.asyncScheduler), (0, rxjs_1.share)()), subscribeObservableOnlyIfEventIsSubscribed);
this.addTypedEventSource(sourceId, eventIdentifierA, sharedSource);

@@ -458,3 +453,3 @@ this.addTypedEventSource(sourceId, eventIdentifierB, sharedSource);

const sourceId = Symbol('');
const sharedSource = this.getDependentObservable(observable.pipe((0, operators_1.delay)(1, rxjs_1.asyncScheduler), (0, operators_1.share)()), subscribeObservableOnlyIfEventIsSubscribed);
const sharedSource = this.getDependentObservable(observable.pipe((0, rxjs_1.delay)(1, rxjs_1.asyncScheduler), (0, rxjs_1.share)()), subscribeObservableOnlyIfEventIsSubscribed);
this.addTypedEventSource(sourceId, eventIdentifierA, sharedSource);

@@ -485,3 +480,3 @@ this.addTypedEventSource(sourceId, eventIdentifierB, sharedSource);

const sourceId = Symbol('');
const sharedSource = this.getDependentObservable(observable.pipe((0, operators_1.delay)(1, rxjs_1.asyncScheduler), (0, operators_1.share)()), subscribeObservableOnlyIfEventIsSubscribed);
const sharedSource = this.getDependentObservable(observable.pipe((0, rxjs_1.delay)(1, rxjs_1.asyncScheduler), (0, rxjs_1.share)()), subscribeObservableOnlyIfEventIsSubscribed);
this.addTypedEventSource(sourceId, eventIdentifierA, sharedSource);

@@ -511,3 +506,3 @@ this.addTypedEventSource(sourceId, eventIdentifierB, sharedSource);

* and share(). So events will always be received asynchronously (expecting synchronous event dispatch would
* be a strong indicator of flawed design, because it could break MVU/reactivity).
* be a strong indicator of flawed design, because it could break reactivity).
* If this store has a parent store, events from both, parent and child will be observed (merged).

@@ -530,3 +525,3 @@ *

.getObservable()
.pipe((0, operators_1.map)(event => ({
.pipe((0, rxjs_1.map)(event => ({
type: identifier,

@@ -587,4 +582,4 @@ event,

return (0, store_utils_1.isBehaviorId)(identifier)
? this.behaviorsSubject.asObservable().pipe((0, operators_1.switchMap)(s => { var _a, _b; return (_b = (_a = s.get(sym)) === null || _a === void 0 ? void 0 : _a.getIsSubscribedObservable()) !== null && _b !== void 0 ? _b : (0, rxjs_1.of)(false); }), (0, operators_1.distinctUntilChanged)(), (0, operators_1.share)())
: this.eventStreamsSubject.asObservable().pipe((0, operators_1.switchMap)(s => { var _a, _b; return (_b = (_a = s.get(sym)) === null || _a === void 0 ? void 0 : _a.getIsSubscribedObservable()) !== null && _b !== void 0 ? _b : (0, rxjs_1.of)(false); }), (0, operators_1.distinctUntilChanged)(), (0, operators_1.share)());
? this.behaviorsSubject.asObservable().pipe((0, rxjs_1.switchMap)(s => { var _a, _b; return (_b = (_a = s.get(sym)) === null || _a === void 0 ? void 0 : _a.getIsSubscribedObservable()) !== null && _b !== void 0 ? _b : (0, rxjs_1.of)(false); }), (0, rxjs_1.distinctUntilChanged)(), (0, rxjs_1.share)())
: this.eventStreamsSubject.asObservable().pipe((0, rxjs_1.switchMap)(s => { var _a, _b; return (_b = (_a = s.get(sym)) === null || _a === void 0 ? void 0 : _a.getIsSubscribedObservable()) !== null && _b !== void 0 ? _b : (0, rxjs_1.of)(false); }), (0, rxjs_1.distinctUntilChanged)(), (0, rxjs_1.share)());
}

@@ -644,6 +639,6 @@ /**

.getIsSubscribedObservable()
.pipe((0, operators_1.switchMap)(isSubscribed => (isSubscribed ? observable : rxjs_1.NEVER)));
.pipe((0, rxjs_1.switchMap)(isSubscribed => (isSubscribed ? observable : rxjs_1.NEVER)));
}
addTypedEventSource(sourceIdentifier, eventIdentifier, sharedSource) {
const source = sharedSource.pipe((0, operators_1.filter)(typedEvent => typedEvent.type === eventIdentifier), (0, operators_1.map)(event => event.event));
const source = sharedSource.pipe((0, rxjs_1.filter)(typedEvent => typedEvent.type === eventIdentifier), (0, rxjs_1.map)(event => event.event));
this.getEventStreamControlledSubject(eventIdentifier).addSource(new source_observable_1.SourceObservable(sourceIdentifier, source, true));

@@ -650,0 +645,0 @@ }

@@ -15,2 +15,15 @@ "use strict";

const operators_1 = require("rxjs/operators");
/**
* This function is a testing utility.
* It takes an observable and the expected number of values to be observed.
* The returned Promise either resolves to an array with the observed values, or rejects on error.
* If the expected number of values is not observed within the configurable timeout, the Promise resolves
* with the values observed so far.
*
* @template T - type for the values to be observed
* @param {Observable} observable - the observable.
* @param {number} length - the expected number of values to be observed before resolving the result-Promise.
* @param {number} timeoutAfter - the timeout for waiting on the expected number of values. Defaults to 3000ms
* @returns {Promise}
*/
const getSequence = (observable, length, timeoutAfter = 3000) => __awaiter(void 0, void 0, void 0, function* () {

@@ -20,8 +33,17 @@ const accObservable = observable.pipe((0, operators_1.scan)((acc, next) => [...acc, next], []), (0, operators_1.startWith)([]));

const combined = (0, rxjs_1.combineLatest)([accObservable, timeoutObservable]);
return combined
.pipe((0, operators_1.filter)(([result, hasTimedOut]) => hasTimedOut || result.length === length), (0, operators_1.map)(([result]) => result), (0, operators_1.take)(1))
.toPromise(); // Deprecated and will be removed in rxjs8
// However, we must still support rxjs 6.x as peer dependency
return (0, rxjs_1.firstValueFrom)(combined.pipe((0, operators_1.filter)(([result, hasTimedOut]) => hasTimedOut || result.length === length), (0, operators_1.map)(([result]) => result), (0, operators_1.take)(1)));
});
exports.getSequence = getSequence;
/**
* This function is a testing utility.
* It takes an observable and array of values.
* The returned Promise resolves as soon as the number of observed values equals the array-length AND the observed values equal the array-values (using expect with .toEqual).
* It rejects in all other cases, e.g. if the expected number of values was not observed within the configurable timeout.
*
* @template T - type for the values to be observed
* @param {Observable} observable - the observable.
* @param {number} sequence - the expected values.
* @param {number} timeoutAfter - the timeout for waiting on the expected values. Defaults to 3000ms
* @returns {Promise}
*/
const expectSequence = (observable, sequence, timeoutAfter = 3000) => __awaiter(void 0, void 0, void 0, function* () {

@@ -33,2 +55,5 @@ return (0, exports.getSequence)(observable, sequence.length, timeoutAfter).then(result => {

exports.expectSequence = expectSequence;
/**
* @internal
*/
const awaitStringifyEqualState = (observable, expectedState, timeoutAfter = 3000) => __awaiter(void 0, void 0, void 0, function* () {

@@ -44,2 +69,5 @@ return new Promise(resolve => {

exports.awaitStringifyEqualState = awaitStringifyEqualState;
/**
* @internal
*/
const awaitError = (observable, timeoutAfter = 3000) => __awaiter(void 0, void 0, void 0, function* () {

@@ -55,8 +83,14 @@ return new Promise(resolve => {

exports.awaitError = awaitError;
/**
* @internal
*/
const awaitCompletion = (observable) => __awaiter(void 0, void 0, void 0, function* () {
return new Promise((resolve, reject) => {
observable.subscribe(() => { }, reject, resolve);
observable.subscribe({ next: () => { }, error: reject, complete: resolve });
});
});
exports.awaitCompletion = awaitCompletion;
/**
* @internal
*/
const withSubscription = (observable, callback) => __awaiter(void 0, void 0, void 0, function* () {

@@ -63,0 +97,0 @@ const subscription = observable.subscribe();

@@ -5,10 +5,9 @@ "use strict";

/**
* This function merges two Record<string, any> T1 and T2, resulting in Merged<T1, T2>
* This function merges two Record\<string, any\> T1 and T2, resulting in Merged\<T1, T2\>
*
* @typedef {function} merge
* @template T1 - type for the first argument
* @template T2 - type for the second argument
* @param {T1} t1 - first argument (extending Record<string, any>).
* @param {T2} t2 - second argument (extending Record<string, any>).
* @returns {Merged<T1, T2>}
* @param {T1} t1 - first argument (extending Record\<string, any\>).
* @param {T2} t2 - second argument (extending Record\<string, any\>).
* @returns {Merged}
*/

@@ -15,0 +14,0 @@ const merge = (t1, t2) => {

@@ -5,7 +5,6 @@ "use strict";

const rxjs_1 = require("rxjs");
const operators_1 = require("rxjs/operators");
const effect_signals_factory_1 = require("./effect-signals-factory");
const store_utils_1 = require("./store-utils");
const resultInputGetter = (store, validationBehaviorId, isValidationResultValid) => store.getBehavior(validationBehaviorId).pipe((0, operators_1.filter)(c => c.resultInput !== undefined && c.result !== undefined), (0, operators_1.filter)(c => c.currentInput === c.resultInput), (0, operators_1.filter)(c => isValidationResultValid(c.result)), // cast is OK, cause we checked for undefined in the first filter
(0, operators_1.map)(c => c.resultInput), (0, operators_1.distinctUntilChanged)(), (0, operators_1.map)(resultInput => resultInput));
const resultInputGetter = (store, validationBehaviorId, isValidationResultValid) => store.getBehavior(validationBehaviorId).pipe((0, rxjs_1.filter)(c => c.resultInput !== undefined && c.result !== undefined), (0, rxjs_1.filter)(c => c.currentInput === c.resultInput), (0, rxjs_1.filter)(c => isValidationResultValid(c.result)), // cast is OK, cause we checked for undefined in the first filter
(0, rxjs_1.map)(c => c.resultInput), (0, rxjs_1.distinctUntilChanged)(), (0, rxjs_1.map)(resultInput => resultInput));
const mapBehaviors = ([v, r], isValidationResultValid) => ({

@@ -24,3 +23,3 @@ currentInput: v.currentInput,

store.getBehavior(outIds.conflicts1.combined),
store.getBehavior(outIds.conflicts2.combined).pipe((0, operators_1.startWith)({
store.getBehavior(outIds.conflicts2.combined).pipe((0, rxjs_1.startWith)({
currentInput: undefined,

@@ -31,6 +30,6 @@ resultInput: undefined,

})),
]).pipe((0, operators_1.filter)(([v, r]) => v.resultPending ||
]).pipe((0, rxjs_1.filter)(([v, r]) => v.resultPending ||
r.currentInput === v.resultInput ||
v.result === undefined ||
!isValidationResultValid(v.result)), (0, operators_1.map)(pair => mapBehaviors(pair, isValidationResultValid)), (0, operators_1.distinctUntilChanged)((a, b) => a.currentInput === b.currentInput &&
!isValidationResultValid(v.result)), (0, rxjs_1.map)(pair => mapBehaviors(pair, isValidationResultValid)), (0, rxjs_1.distinctUntilChanged)((a, b) => a.currentInput === b.currentInput &&
a.isValid === b.isValid &&

@@ -45,3 +44,3 @@ a.result === b.result &&

/**
* Generic function to create a specific ValidatedInputWithResultFactory.
* Generic function to create a specific {@link ValidatedInputWithResultFactory}.
*/

@@ -48,0 +47,0 @@ const getValidatedInputWithResultSignalsFactory = () => (0, effect_signals_factory_1.getEffectSignalsFactory)()

@@ -1,6 +0,1 @@

export declare class ContextHandle {
private active;
get isInContext(): boolean;
withContext(cb: () => void): void;
}
export default ContextHandle;

@@ -0,1 +1,4 @@

/**
* @internal
*/
export class ContextHandle {

@@ -2,0 +5,0 @@ constructor() {

@@ -1,41 +0,1 @@

import { Observable } from 'rxjs';
import { DelayedEventQueue } from './delayed-event-queue';
import { SourceObservable } from './source-observable';
export interface ResetHandle {
removeSources(): void;
readdSources(): void;
}
export declare class ControlledSubject<T> {
private readonly id;
private readonly isBehavior;
private readonly onSourceError;
private readonly onSourceCompleted;
private readonly delayedEventQueue;
private subject;
private pipe;
private readonly lazySources;
private readonly statefulSources;
private observable;
private isSubscribed;
private readonly isSubscribedSubject;
private selfSubscriptionOrPendingSubscription;
private nTargetSubscriptions;
private readonly contextHandle;
constructor(id: symbol, isBehavior: boolean, onSourceError: (sourceId: symbol, error: any) => void, onSourceCompleted: (sourceId: symbol) => void, delayedEventQueue: DelayedEventQueue);
getObservable(): Observable<T>;
getIsSubscribedObservable(): Observable<boolean>;
addSource(source: SourceObservable<T>): void;
removeSource(sourceId: symbol): void;
removeAllSources(): void;
next(next: T): void;
error(error: any): void;
complete(): void;
isObservableSubscribed(): boolean;
getResetHandle(): ResetHandle;
hasSource(sourceId: symbol): boolean;
getNumberOfSources(): number;
private getNewTargetPipe;
private unsubscribeSelf;
private setIsSubscribed;
private subscribeSource;
}
export {};
/* eslint no-underscore-dangle: ["error", { "allow": ["_rxs_id"] }] */
import { BehaviorSubject, Observable, Subject } from 'rxjs';
import { distinctUntilChanged, filter, share } from 'rxjs/operators';
import { BehaviorSubject, distinctUntilChanged, filter, Observable, share, Subject, } from 'rxjs';
import { ContextHandle } from './context-handle';
import { NO_VALUE } from './store-utils';
/**
* Used by the {@link Store}
*
* @internal
*/
export class ControlledSubject {

@@ -7,0 +11,0 @@ constructor(id, isBehavior, onSourceError, onSourceCompleted, delayedEventQueue) {

@@ -1,9 +0,1 @@

import { Observable } from 'rxjs';
export declare class DelayedEventQueue {
private queueArray;
getQueueDelayedObservable<T>(observable: Observable<T>): Observable<T>;
private fromDelayedQueue;
private queueSubject;
private signalNext;
}
export default DelayedEventQueue;

@@ -1,3 +0,7 @@

import { Subject } from 'rxjs';
import { map, mergeMap } from 'rxjs/operators';
import { map, mergeMap, Subject } from 'rxjs';
/**
* Used by the {@link Store}
*
* @internal
*/
export class DelayedEventQueue {

@@ -4,0 +8,0 @@ constructor() {

@@ -5,89 +5,84 @@ import { Signals, SignalsFactory } from './signals-factory';

/**
* This specifies the type for the lazy behavior produced by EffectSignals.
* Value-type for the derived behavior produced by {@link EffectSignals}.
*
* @typedef {object} CombinedEffectResult<Input, Result> - type for the behavior produced by effect signal factories
* @template Input - specifies the input type for the effect
* @template Result - specifies the result type of the effect
* @property {Input | undefined} currentInput - current input (which might differ from the resultInput)
* @property {Input | undefined} resultInput - the input that produced the current result (or undefined, if result is undefined)
* @property {Result | undefined} result - the current result (or undefined, if no result was received yet)
* @property {boolean} resultPending - indicates whether the effect is currently running. (In case of a factory without trigger, this will be true whenever currentInput !== resultInput, or whenever an invalidation event has been sent)
*/
export declare type CombinedEffectResult<Input, Result> = {
/** current input (which might differ from the resultInput) */
currentInput?: Input;
/** the current result (or undefined, if no result was received yet) */
result?: Result;
/** the input that produced the current result (or undefined, if result is undefined) */
resultInput?: Input;
/** indicates whether the effect is currently running. (In case of a factory without trigger, this will be true whenever currentInput !== resultInput, or whenever an invalidation event has been sent) */
resultPending: boolean;
};
/**
* Type for error events produced by an EffectSignals (unhandled effect errors).
* Value-type for error events produced by an {@link EffectSignals} (unhandled effect errors).
*
* @typedef {object} EffectError<Input> - type for error events produced by EffectSignals
* @template Input - specifies the input type for the effect
* @property {any} error - the unhandled error thrown by an effect
* @property {Input} errorInput - the effect input that lead to the error
*/
export declare type EffectError<Input> = {
/** the unhandled error thrown by an effect */
error: any;
/** the effect input that lead to the error */
errorInput: Input;
};
/**
* Type for success events produced by EffectSignals.
* Value-type for success events produced by {@link EffectSignals}.
*
* @typedef {object} EffectSuccess<Input, Result> - type for success events produced by EffectSignals
* @template Input - specifies the input type for the effect
* @template Result - specifies the result type of the effect
* @property {Result} result - the effect result
* @property {Input} resultInput - the effect input that lead to the result
* @property {Input | undefined} previousInput - the input of the previous result, or undefined
* @property {Result | undefined} previousResult - the previous result, or undefined
*/
export declare type EffectSuccess<Input, Result> = {
/** the effect result */
result: Result;
/** the effect input that lead to the result */
resultInput: Input;
/** the input of the previous result, or undefined */
previousInput?: Input;
/** the previous result, or undefined */
previousResult?: Result;
};
/**
* Type specifying the input EffectSignals (the corresponding signal-sources are NOT added to the store
* Type specifying the input {@link EffectSignals} (the corresponding signal-sources are NOT added to the store
* by the EffectSignals-setup, but by whoever uses the signals, e.g. by extendSetup or fmap or just using dispatch).
* The EffectSignalsFactory gives you the guarantee, that invalidate-events are NOT missed, even while
* The {@link EffectSignalsFactory} gives you the guarantee, that invalidate-events are NOT missed, even while
* the combined-behavior is not subscribed.
*
* @typedef {object} EffectInputSignals<Input> - object holding the input signal identifiers for EffectSignals
* @template Input - specifies the input type for the effect
* @property {DerivedId<Input>} input - identifier for the behavior being consumed by EffectSignals as input
* @property {EventId<undefined>} invalidate - identifier for the invalidation event that can be dispatched to trigger re-evaluation of the current input under the given effect
* @property {EventId<undefined>} trigger - identifier for the trigger event that can be dispatched to trigger the given effect. This event has only meaning, if withTrigger is configured (see EffectConfiguration)
*/
export declare type EffectInputSignals<Input> = {
/** identifier for the behavior being consumed by EffectSignals as input (see {@link EffectConfiguration} on how to configure your factory to subscribe the corresponding behavior eagerly) */
input: DerivedId<Input>;
/** identifier for the invalidation event that can be dispatched to trigger re-evaluation of the current input under the given effect */
invalidate: EventId<undefined>;
/** identifier for the trigger event that can be dispatched to trigger the given effect. This event has only meaning, if withTrigger is configured (see EffectConfiguration) */
trigger: EventId<undefined>;
};
/**
* Type specifying the output EffectSignals (signals produced EffectSignals).
* Type specifying the output {@link EffectSignals} (signals produced EffectSignals).
* The {@link EffectSignalsFactory} takes care that subscribing error- or success-events keeps the effect itself lazy (hence only subscribing the combined behavior will subscribe the effect itself).
*
* @typedef {object} EffectOutputSignals<Input, Result> - object holding the output signal identifiers
* @template Input - specifies the input type for the effect
* @template Result - specifies the result type of the effect
* @property {DerivedId<CombinedEffectResult<Input, Result>>} combined - identifier for the produced combined effect result behavior
* @property {EventId<EffectError<Input>>} errors - identifier for the produced error events
* @property {EventId<EffectSuccess<Input, Result>>} successes - identifier for the produced success events
*/
export declare type EffectOutputSignals<Input, Result> = {
/** identifier for the produced combined effect result behavior */
combined: DerivedId<CombinedEffectResult<Input, Result>>;
/** identifier for the produced error events */
errors: EventId<EffectError<Input>>;
/** identifier for the produced success events */
successes: EventId<EffectSuccess<Input, Result>>;
};
/**
* Type specifying the effects-type of EffectSignals (the corresponding effects are NOT added to the store
* Type specifying the effect-type of {@link EffectSignals} (the corresponding effects are NOT added to the store
* by the EffectSignals-setup, but by whoever uses the signals, e.g. by useExistingEffect or via extended configuration plus extendSetup).
*
* @typedef {object} EffectFactoryEffects<Input> - object holding the effect identifiers for EffectSignals
* @template Input - specifies the input type for the effect
* @template Result - specifies the result type of the effect
* @property {EffectId<Input, Result>} id - the id for the specific Effect function to be used
*/
export declare type EffectFactoryEffects<Input, Result> = {
/** the id for the specific Effect function to be used */
id: EffectId<Input, Result>;

@@ -98,2 +93,3 @@ };

* They fulfill the following requirements:
* ```markdown
* 1.) The produced CombinedEffectResult<Input, Result> behavior must be lazy, hence, as long as it is not subscribed,

@@ -107,6 +103,6 @@ * no effect will be triggered.

* subscribe the result behavior.
* ```
*
* See the documentation for EffectConfiguration<Input, Result> for further configuration of EffectSignals<Input, Result>.
* See the documentation for {@link EffectConfiguration} for further configuration of EffectSignals.
*
* @typedef {object} EffectSignals<Input, Result>
* @template Input - specifies the input type for the effect

@@ -117,28 +113,26 @@ * @template Result - specifies the result type of the effect

/**
* This type specifies the type of the argument to EffectSignalsBuild, hence the configuration of EffectSignals.
* This type specifies the type of the argument to {@link EffectSignalsBuild}, hence the configuration of {@link EffectSignals}.
*
* @typedef {object} EffectConfiguration<Input, Result>
* @template Input - specifies the input type for the effect
* @template Result - specifies the result type of the effect
* @property {function | undefined} effectInputEquals - optional function used to determine whether a new input equals the previous one. Defaults to strict equals (a === b)
* @property {boolean | undefined} withTrigger - optional bool that defaults to false. If true, the effect will only be performed in case a trigger event is received (else, whenever the input changes).
* @property {function | undefined} initialResultGetter - optional function that defaults to undefined. If not undefined, it will be used to determine an initial result for the result behavior.
* @property {number | undefined} effectDebounceTime - optional number that defaults to undefined. If a number > 0 is specified, then it will be used as milliseconds to debounce new input to the effect (please DON't debounce the input signal yourself, because that would debounce before trigger and/or input equals).
* @property {function | undefined} wrapperEffectGetter - optional function to wrap the effect defined by effectId with a custom Effect
* @property {boolean | undefined} eagerInputSubscription - optional bool to specify whether the input behavior should be subscribed eagerly (defaults to false)
* @property {string | undefined} nameExtension - optional string to be used as argument to calls of getBehaviorId and getEventId
*/
export declare type EffectConfiguration<Input, Result> = {
/** Function used to determine whether a new input equals the previous one. Defaults to strict equals (a === b) */
effectInputEquals?: (a: Input, b: Input) => boolean;
/** Defaults to false. If true, the effect will only be performed in case a trigger event is received (else, whenever the input changes) */
withTrigger?: boolean;
/** If defined, this function will be used to determine an initial result for the result behavior */
initialResultGetter?: () => Result;
/** If defined and >0, then it will be used as milliseconds to debounce new input to the effect (please DON't debounce the input signal yourself, because that would debounce before trigger and/or input equals!) */
effectDebounceTime?: number;
/** Function to wrap the effect defined by effectId with a custom Effect */
wrappedEffectGetter?: (effect: Effect<Input, Result>) => Effect<Input, Result>;
/** Specifies whether the input behavior should be subscribed eagerly (defaults to false) */
eagerInputSubscription?: boolean;
/** Optional string to be used as argument to calls of getBehaviorId and getEventId */
nameExtension?: string;
};
/**
* Type specifying the SignalsBuild function for EffectSignals.
* Type specifying the {@link SignalsBuild} function for {@link EffectSignals}, hence a function taking an {@link EffectConfiguration} and producing EffectSignals.
*
* @typedef {function} EffectSignalsBuild - function taking an EffectConfiguration and producing EffectSignals
* @template Input - specifies the input type for the effect

@@ -150,5 +144,4 @@ * @template Result - specifies the result type of the effect

/**
* This type specifies a SignalsFactory wrapping EffectSignals.
* This type specifies a {@link SignalsFactory} wrapping {@link EffectSignals}.
*
* @typedef {object} EffectSignalsFactory<Input, Result>
* @template Input - specifies the input type for the effect

@@ -159,3 +152,3 @@ * @template Result - specifies the result type of the effect

/**
* This function creates an EffectSignalsFactory<Input, Result>.
* This function creates an {@link EffectSignalsFactory}.
*

@@ -162,0 +155,0 @@ * @template Input - specifies the input type for the effect

@@ -1,3 +0,2 @@

import { combineLatest, of, throwError } from 'rxjs';
import { catchError, debounceTime, filter, map, switchMap, take } from 'rxjs/operators';
import { catchError, combineLatest, debounceTime, filter, map, of, switchMap, take, throwError, } from 'rxjs';
import { SignalsFactory } from './signals-factory';

@@ -51,3 +50,3 @@ import { getDerivedId, getEffectId, getEventId, getStateId, NO_VALUE, } from './store-utils';

// It is important to setup the combined observable as behavior,
// because a simple shareReplay (even with refCount) would create a memory leak!!!
// because a simple shareReplay (even with refCount) could create a memory leak!!!
const combinedId = getDerivedId();

@@ -128,3 +127,3 @@ store.addDerivedState(combinedId, combineLatest([

/**
* This function creates an EffectSignalsFactory<Input, Result>.
* This function creates an {@link EffectSignalsFactory}.
*

@@ -131,0 +130,0 @@ * @template Input - specifies the input type for the effect

@@ -6,3 +6,4 @@ export * from './effect-signals-factory';

export * from './store-utils';
export { Configuration, KeysOfValueType, Merged, MergedConfiguration, WithValueType, } from './type-utils';
export { expectSequence, getSequence } from './test-utils/test-utils';
export * from './type-utils';
export * from './validated-input-with-result-signals-factory';

@@ -6,3 +6,5 @@ export * from './effect-signals-factory';

export * from './store-utils';
export { expectSequence, getSequence } from './test-utils/test-utils';
export * from './type-utils';
export * from './validated-input-with-result-signals-factory';
//# sourceMappingURL=index.js.map
import { SignalsFactory } from './signals-factory';
import { BehaviorId, EventId } from './store-utils';
/**
* Type specifying the input signal ids produced by a ModelSignalsFactory (the corresponding signal-sources
* Type specifying the input signal ids produced by a {@link ModelSignalsFactory} (the corresponding signal-sources
* are NOT added to the store by the signals-setup, but by whoever uses the signals, e.g. by extendSetup or fmap or just using dispatch).
*
* @typedef {object} ModelInputSignals<T> - object holding the input signal identifiers for ModelSignals
* @template T - the type of the model to be handled
* @property {EventId<T>} setModel - identifier for the event to replace the complete model
* @property {EventId<Partial<T>>} updateModel - identifier for the event to update the model by a given partial model
* @property {EventId<undefined>} resetModel - identifier for the event to reset the model to the configured default
*/
export declare type ModelInputSignals<T> = {
/** identifier for the event to replace the complete model */
setModel: EventId<T>;
/** identifier for the event to update the model by a given partial model */
updateModel: EventId<Partial<T>>;
/** identifier for the event to reset the model to the configured default */
resetModel: EventId<undefined>;
};
/**
* Type specifying the output signal ids produced by a ModelSignalsFactory.
* Type specifying the output signal ids produced by a {@link ModelSignalsFactory}.
*
* @typedef {object} ModelOutputSignals<T> - object holding the output signal identifiers for ModelSignals
* @template T - the type of the model to be handled
* @property {StateId<T>} model - identifier for the model behavior
*/
export declare type ModelOutputSignals<T> = {
/** identifier for the model behavior (on purpose no StateId to keep encapsulation, cause BehaviorId cannot be used to add more reducers) */
model: BehaviorId<T>;
};
/**
* Type specifying the configuration of a ModelSignalsFactory.
* Type specifying the configuration of a {@link ModelSignalsFactory}.
*
* @typedef {object} ModelConfig<T> - object holding the configuration for ModelSignals
* @template T - the type of the model to be handled
* @property {T} defaultModel - the default model
* @property {string | undefined} nameExtension - optional string to be used as argument to calls of getBehaviorId and getEventId
*/
export declare type ModelConfig<T> = {
/** the default model */
defaultModel: T;
/** optional string to be used as argument to calls of getBehaviorId and getEventId */
nameExtension?: string;
};
/**
* This type specifies a generic SignalsFactory to handle arbitrary models.
* This type specifies a generic {@link SignalsFactory} to handle arbitrary models.
*
* @typedef {object} ModelSignalsFactory<T>
* @template T - specifies the type of the model

@@ -48,3 +44,3 @@ */

/**
* This function creates a ModelSignalsFactory<T>.
* This function creates a {@link ModelSignalsFactory}.
*

@@ -51,0 +47,0 @@ * @template T - specifies the type of the model

@@ -28,3 +28,3 @@ import { SignalsFactory } from './signals-factory';

/**
* This function creates a ModelSignalsFactory<T>.
* This function creates a {@link ModelSignalsFactory}.
*

@@ -31,0 +31,0 @@ * @template T - specifies the type of the model

@@ -6,5 +6,3 @@ import { Observable } from 'rxjs';

/**
* This type defines an object that maps identifier names to signal ids or nested NameToSignalIds.
*
* @typedef {object} NameToSignalId - maps strings on SignalId<any> | NameToSignalId
* This type defines an object that maps identifier names to {@link SignalId}s or nested {@link NameToSignalId}s.
*/

@@ -15,5 +13,3 @@ export declare type NameToSignalId = {

/**
* This type defines an object that maps identifier names to effect ids or nested NameToEffectIds.
*
* @typedef {object} NameToEffectId - maps strings on EffectId<any, any> | NameToSignalId
* This type defines an object that maps identifier names to {@link EffectId}s or nested {@link NameToEffectId}s.
*/

@@ -24,7 +20,6 @@ export declare type NameToEffectId = {

/**
* This type defines an object that holds input and output signal-ids of a Signals type.
* This type defines an object that holds input and output {@link SignalId}s of a {@link Signals} type.
*
* @template IN - NameToSignalId defining input signals-ids
* @template OUT - NameToSignalId defining output signals-ids
* @typedef {object} SignalIds - holds input- and output- NameToSignalId objects
* @template IN - {@link NameToSignalId} defining input signals-ids
* @template OUT - {@link NameToSignalId} defining output signals-ids
*/

@@ -36,6 +31,5 @@ export declare type SignalIds<IN extends NameToSignalId, OUT extends NameToSignalId> = {

/**
* This type defines an object that holds effect-ids of a Signals type.
* This type defines an object that holds {@link EffectId}s of a {@link Signals} type.
*
* @template EFF - NameToEffectId defining effect-ids
* @typedef {object} EffectIds - holds NameToEffectId object
* @template EFF - {@link NameToEffectId} defining effect-ids
*/

@@ -46,6 +40,4 @@ export declare type EffectIds<EFF extends NameToEffectId> = {

/**
* This type defines an object with a function 'setup' that takes a store instance
* This type defines an object with a function 'setup' that takes a {@link Store} instance
* as argument and executes the required setup (wireing) to produce certain output signals.
*
* @typedef {object} SetupWithStore - has a function setup(store) => void
*/

@@ -56,5 +48,5 @@ export declare type SetupWithStore = {

/**
* This type defines an immutable object that encapsulates SignalIds, SetupWithStore and EffectIds.
* The setup method creates all the necessary wireing to configure the store for the SignalIds.
* The Signals type represents the reactive counterpart to a class-instance (the IN/OUT-NameToSignalId
* This type defines an immutable object that encapsulates {@link SignalIds}, {@link SetupWithStore} and {@link EffectIds}.
* The setup method creates all the necessary wireing to configure the {@link Store} instance for the SignalIds.
* The Signals type represents the reactive counterpart to a class-instance (the IN/OUT-{@link NameToSignalId}
* being the counterpart to a class-interface).

@@ -64,10 +56,9 @@ * SetupWithStore must add sources to the store for all output-ids, but it must NOT add sources for

*
* @typedef {object} Signals<IN, OUT, EFF> - composition of SetupWithStore, SignalIds<IN, OUT> and EffectIds<EFF>
* @template IN - concrete NameToSignalIds defining input signal-ids. SetupWithStore does NOT add corresponding signals to the store (hence this must be done by the user of this Signals object, e.g. via connect)
* @template OUT - concrete NameToSignalIds defining output signal-ids. In contrast to the input signal-ids, the SetupWithStore method takes care of setting up corresponding signals in the store.
* @template EFF - concrete NameToEffectIds defining effect-ids. SetupWithStore does NOT add corresponding effects to the store (hence this must be done by the user of this Signals object)
* @template IN - concrete {@link NameToSignalId} defining input signal-ids. SetupWithStore does NOT add corresponding signals to the store (hence this must be done by the user of this Signals object, e.g. via connect)
* @template OUT - concrete {@link NameToSignalId} defining output signal-ids. In contrast to the input signal-ids, the SetupWithStore method takes care of setting up corresponding signals in the store.
* @template EFF - concrete {@link NameToEffectId} defining effect-ids. SetupWithStore does NOT add corresponding effects to the store (hence this must be done by the user of this Signals object)
*/
export declare type Signals<IN extends NameToSignalId, OUT extends NameToSignalId, EFF extends NameToEffectId = {}> = SetupWithStore & SignalIds<IN, OUT> & EffectIds<EFF>;
/**
* This type defines a function taking some config-object as argument and returning a Signals object.
* This type defines a function taking some config-object as argument and returning a {@link Signals} object, hence the type being used as constructor argument for {@link SignalsFactory}.
* It creates input- and output-ids, as well as effect-ids.

@@ -77,65 +68,60 @@ * It is the reactive counterpart of a class/class-constructor.

* for the output-ids. For the input-ids, corresponding signals must be setup somewhere else (e.g. via store.connect).
* If you have a scenario, where setup needs a SignalId that is NOT created by SignalsBuild, then you can pass it via CONFIG.
* If you have a scenario, where setup needs a {@link SignalId} that is NOT created by {@link SignalsBuild}, then you can pass it via CONFIG.
* The same holds true for effects (no effects for the generated effect-ids will be added to the store).
* (see SignalsFactory::useExistingEffect on how to delegate from a generated effect-id to an existing effect)
* (see {@link SignalsFactory.useExistingEffect} on how to delegate from a generated effect-id to an existing effect)
*
* @typedef {function} SignalsBuild<IN, OUT, CONFIG, EFF> - constructor argument of SignalsFactories
* @template IN - concrete NameToSignalIds defining input signal-ids of the resulting Signals object
* @template OUT - concrete NameToSignalIds defining output signal-ids of the resulting Signals object
* @template CONFIG - concrete Configuration for the given SignalsBuild
* @template EFF - concrete NameToEffectIds defining effect-ids of the resulting Signals object
* @template IN - concrete {@link NameToSignalId} defining input signal-ids of the resulting Signals object
* @template OUT - concrete {@link NameToSignalId} defining output signal-ids of the resulting Signals object
* @template CONFIG - concrete {@link Configuration} for the given SignalsBuild
* @template EFF - concrete {@link NameToEffectId} defining effect-ids of the resulting Signals object
*/
export declare type SignalsBuild<IN extends NameToSignalId, OUT extends NameToSignalId, CONFIG extends Configuration, EFF extends NameToEffectId> = (config: CONFIG) => Signals<IN, OUT, EFF>;
/**
* This type specifies a function mapping from SignalsBuild<IN1, OUT1, CONFIG1, EFF1> to a SignalsFactory<IN2, OUT2, CONFIG2, EFF2>,
* hence the argument to the monadic-bind method of a SignalsFactory<IN1, OUT1, CONFIG1, EFF1>.
* This type specifies a function mapping from ```SignalsBuild<IN1, OUT1, CONFIG1, EFF1>``` to ```SignalsFactory<IN2, OUT2, CONFIG2, EFF2>```,
* hence the argument to the monadic-bind method of a {@link SignalsFactory}.
*
* @typedef {function} BindMapper<IN1, OUT1, CONFIG1, EFF1, IN2, OUT2, CONFIG2, EFF2> - function mapping from SignalsBuild<IN1, OUT1, CONFIG1, EFF1> to SignalsFactory<IN2, OUT2, CONFIG2, EFF2>
* @template IN1 - concrete NameToSignalIds defining input-ids produced by the given SignalsBuild
* @template OUT1 - concrete NameToSignalIds defining output-ids produced by the given SignalsBuild
* @template CONFIG1 - concrete Configuration for the given SignalsBuild
* @template EFF1 - concrete NameToEffectIds defining effect-ids produced by the given SignalsBuild
* @template IN2 - concrete NameToSignalIds defining input signal-ids of the resulting SignalsFactory
* @template OUT2 - concrete NameToSignalIds defining output signal-ids of the resulting SignalsFactory
* @template CONFIG2 - concrete Configuration for the resulting SignalsFactory
* @template EFF2 - concrete NameToEffectIds defining effect-ids of the resulting SignalsFactory
* @template IN1 - concrete {@link NameToSignalId} defining input-ids produced by the given SignalsBuild
* @template OUT1 - concrete {@link NameToSignalId} defining output-ids produced by the given SignalsBuild
* @template CONFIG1 - concrete {@link Configuration} for the given SignalsBuild
* @template EFF1 - concrete {@link NameToEffectId} defining effect-ids produced by the given SignalsBuild
* @template IN2 - concrete {@link NameToSignalId} defining input signal-ids of the resulting SignalsFactory
* @template OUT2 - concrete {@link NameToSignalId} defining output signal-ids of the resulting SignalsFactory
* @template CONFIG2 - concrete {@link Configuration} for the resulting SignalsFactory
* @template EFF2 - concrete {@link NameToEffectId} defining effect-ids of the resulting SignalsFactory
*/
export declare type BindMapper<IN1 extends NameToSignalId, OUT1 extends NameToSignalId, CONFIG1 extends Configuration, EFF1 extends NameToEffectId, IN2 extends NameToSignalId, OUT2 extends NameToSignalId, CONFIG2 extends Configuration, EFF2 extends NameToEffectId> = (signalsBuild: SignalsBuild<IN1, OUT1, CONFIG1, EFF1>) => SignalsFactory<IN2, OUT2, CONFIG2, EFF2>;
/**
* This type specifies a function mapping from SignalsBuild<IN1, OUT1, CONFIG1, EFF1> to SignalsBuild<IN2, OUT2, CONFIG2, EFF2>,
* hence the argument to the functor-map-method of a SignalsFactory<IN1, OUT1, CONFIG1, EFF1>.
* This type specifies a function mapping from ```SignalsBuild<IN1, OUT1, CONFIG1, EFF1>``` to ```SignalsBuild<IN2, OUT2, CONFIG2, EFF2>```,
* hence the argument to the functor-map-method of a {@link SignalsFactory}.
*
* @typedef {function} BuildMapper<IN1, OUT1, CONFIG1, EFF1, IN2, OUT2, CONFIG2, EFF2> - function mapping from SignalsBuild<IN1, OUT1, CONFIG1, EFF1> to SignalsBuild<IN2, OUT2, CONFIG2, EFF2>
* @template IN1 - concrete NameToSignalIds defining input signal-ids produced by the given SignalsBuild<IN1, OUT1, CONFIG1, EFF1>
* @template OUT1 - concrete NameToSignalIds defining output signal-ids produced by the given SignalsBuild<IN1, OUT1, CONFIG1, EFF1>
* @template CONFIG1 - concrete Configuration for the given SignalsBuild<IN1, OUT1, CONFIG1, EFF1>
* @template EFF1 - concrete NameToEffectIds produced by the given SignalsBuild<IN1, OUT1, CONFIG1, EFF1>
* @template IN2 - concrete NameToSignalIds defining input signals-ids produced by the resulting SignalsBuild<IN2, OUT2, CONFIG2, EFF2>
* @template OUT2 - concrete NameToSignalIds defining output signal-ids produced by the resulting SignalsBuild<IN2, OUT2, CONFIG2, EFF2>
* @template CONFIG2 - concrete Configuration for the resulting SignalsBuild<IN2, OUT2, CONFIG2, EFF2>
* @template EFF2 - concrete NameToEffectIds produced by the resulting SignalsBuild<IN2, OUT2, CONFIG2, EFF2>
* @template IN1 - concrete {@link NameToSignalId} defining input signal-ids produced by the given SignalsBuild
* @template OUT1 - concrete {@link NameToSignalId} defining output signal-ids produced by the given SignalsBuild
* @template CONFIG1 - concrete {@link Configuration} for the given SignalsBuild
* @template EFF1 - concrete {@link NameToEffectId} produced by the given SignalsBuild
* @template IN2 - concrete {@link NameToSignalId} defining input signals-ids produced by the resulting SignalsBuild
* @template OUT2 - concrete {@link NameToSignalId} defining output signal-ids produced by the resulting SignalsBuild
* @template CONFIG2 - concrete {@link Configuration} for the resulting SignalsBuild
* @template EFF2 - concrete {@link NameToEffectId} produced by the resulting SignalsBuild
*/
export declare type BuildMapper<IN1 extends NameToSignalId, OUT1 extends NameToSignalId, CONFIG1 extends Configuration, EFF1 extends NameToEffectId, IN2 extends NameToSignalId, OUT2 extends NameToSignalId, CONFIG2 extends Configuration, EFF2 extends NameToEffectId> = (signalsBuild: SignalsBuild<IN1, OUT1, CONFIG1, EFF1>) => SignalsBuild<IN2, OUT2, CONFIG2, EFF2>;
/**
* This type specifies the result of the SignalsFactory compose method.
* This type specifies the result of the {@link SignalsFactory.compose} method.
*
* @typedef {object} ComposedFactory<IN1, OUT1, CONFIG1, EFF1, IN2, OUT2, CONFIG2, EFF2> - result of the composition of SignalsFactory<IN1, OUT1, CONFIG1, EFF1> and SignalsFactory<IN2, OUT2, CONFIG2, EFF2>
* @template IN1 - concrete NameToSignalIds defining input signal-ids of a SignalsFactory<IN1, OUT1, CONFIG1, EFF1>
* @template OUT1 - concrete NameToSignalIds defining output signal-ids of a SignalsFactory<IN1, OUT1, CONFIG1, EFF1>
* @template CONFIG1 - concrete Configuration of a SignalsFactory<IN1, OUT1, CONFIG1, EFF1>
* @template EFF1 - concrete NameToEffectIds of a SignalsFactory<IN1, OUT1, CONFIG1, EFF1>
* @template IN2 - concrete NameToSignalIds defining input signal-ids of a SignalsFactory<IN2, OUT2, CONFIG2, EFF2>
* @template OUT2 - concrete NameToSignalIds defining output signal-ids of a SignalsFactory<IN2, OUT2, CONFIG2, EFF2>
* @template CONFIG2 - concrete Configuration of a SignalsFactory<IN2, OUT2, CONFIG2, EFF2>
* @template EFF1 - concrete NameToEffectIds of a SignalsFactory<IN2, OUT2, CONFIG2, EFF2>
* @template IN1 - concrete {@link NameToSignalId} defining input signal-ids of SignalsFactory1
* @template OUT1 - concrete {@link NameToSignalId} defining output signal-ids of SignalsFactory1
* @template CONFIG1 - concrete {@link Configuration} of SignalsFactory1
* @template EFF1 - concrete {@link NameToEffectId} of SignalsFactory1
* @template IN2 - concrete {@link NameToSignalId} defining input signal-ids of SignalsFactory2
* @template OUT2 - concrete {@link NameToSignalId} defining output signal-ids of SignalsFactory2
* @template CONFIG2 - concrete {@link Configuration} of SignalsFactory2
* @template EFF1 - concrete {@link NameToEffectId} of SignalsFactory2
*/
export declare type ComposedFactory<IN1 extends NameToSignalId, OUT1 extends NameToSignalId, CONFIG1 extends Configuration, EFF1 extends NameToEffectId, IN2 extends NameToSignalId, OUT2 extends NameToSignalId, CONFIG2 extends Configuration, EFF2 extends NameToEffectId> = SignalsFactory<Merged<IN1, IN2>, Merged<OUT1, OUT2>, MergedConfiguration<CONFIG1, CONFIG2>, Merged<EFF1, EFF2>>;
/**
* This type specifies the argument to the extendSetup-method of SignalFactories.
* This type specifies the argument to the {@link SignalsFactory.extendSetup} method.
*
* @typedef {function} ExtendSetup<IN, OUT, CONFIG> - function consuming store, input, output and configuration of a SignalsFactory
* @template IN - concrete NameToSignalIds defining input signal-ids of a SignalsFactory<IN, OUT, CONFIG, EFF>
* @template OUT - concrete NameToSignalIds defining output signal-ids of a SignalsFactory<IN, OUT, CONFIG, EFF>
* @template CONFIG - concrete Configuration of a SignalsFactory<IN, OUT, CONFIG, EFF>
* @template EFF - concrete NameToEffectIds of a SignalsFactory<IN, OUT, CONFIG, EFF>
* @template IN - concrete {@link NameToSignalId} defining input signal-ids of a SignalsFactory
* @template OUT - concrete {@link NameToSignalId} defining output signal-ids of a SignalsFactory
* @template CONFIG - concrete {@link Configuration} of a SignalsFactory
* @template EFF - concrete {@link NameToEffectId} of a SignalsFactory
*/

@@ -148,13 +134,17 @@ export declare type ExtendSetup<IN extends NameToSignalId, OUT extends NameToSignalId, CONFIG extends Configuration, EFF extends NameToEffectId> = (store: Store, input: IN, output: OUT, config: CONFIG, effects: EFF) => void;

/**
* Function mapping from one concrete NameToSignalId to another NameToSignalId
* Function mapping from one concrete {@link NameToSignalId} to another {@link NameToSignalId}
*/
export declare type MapSignalIds<T1 extends NameToSignalId, T2 extends NameToSignalId, CONFIG> = (ids: T1, config: CONFIG) => T2;
/**
* Function mapping from one concrete NameToEffectId to another NameToEffectId
* Function mapping from one concrete {@link NameToEffectId} to another {@link NameToEffectId}
*/
export declare type MapEffectIds<T1 extends NameToEffectId, T2 extends NameToEffectId, CONFIG> = (ids: T1, config: CONFIG) => T2;
/**
* AddSignalId is the result type of adding a key in a NameToSignalId.
* AddSignalId is the result type of adding a key in a {@link NameToSignalId} (also see the difference to {@link AddOrReplaceId}).
*
* @typedef {object} AddSignalId<T, N, ID> - the result of adding { [N]: ID; } on T
* ```ts
* AddSignalId<{ a: EventId<number> }, 'a', EventId<string> -> { a: EventId<never> }
* AddSignalId<{ a: EventId<number> }, 'b', EventId<string> -> { a: EventId<number>; b: EventId<string> }
* ```
*
* @template T - concrete NameToSignalIds

@@ -168,5 +158,10 @@ * @template N - string key

/**
* AddOrReplaceId is the result type of adding or replacing a key in a NameToSignalId.
* AddOrReplaceId is the result type of adding or replacing a key in a {@link NameToSignalId}.
*
* @typedef {object} AddOrReplaceId<T, N, ID> - the result of adding or replacing { [N]: ID; } on T
* ```ts
* AddOrReplaceId<{ a: EventId<number> }, 'a', EventId<string> -> { a: EventId<string> }
* AddOrReplaceId<{ a: EventId<number> }, 'b', EventId<string> -> { a: EventId<number>; b: EventId<string> }
* ```
*
* @typedef {object} AddOrReplaceId
* @template T - concrete NameToSignalIds

@@ -180,5 +175,9 @@ * @template N - string key

/**
* AddEffectId is the result type of adding a key in a NameToEffectId.
* AddEffectId is the result type of adding a key in a {@link NameToEffectId}.
*
* @typedef {object} AddEffectId<T, N, ID> - the result of adding { [N]: ID; } on T
* ```ts
* AddEffectId<{ a: EffectId<number, string> }, N, ID> -> { a: EffectId<number, string>; [N]: ID }
* ```
*
* @typedef {object} AddEffectId
* @template T - concrete NameToEffectIds

@@ -192,5 +191,9 @@ * @template N - string key

/**
* RenameId is the result type of renaming a key in a NameToSignalId.
* RenameId is the result type of renaming a key in a {@link NameToSignalId}.
*
* @typedef {object} RenameId<T extends NameToSignalId, N1 extends keyof T, N2 extends string> - the result type of { [N1]: T[N1]; } -> { [N2]: T[N1]; }
* ```ts
* RenameId<{ [N1]: T[N1] }> -> { [N2]: T[N1] }
* ```
*
* @typedef {object} RenameId
* @template T - concrete NameToSignalIds

@@ -204,5 +207,9 @@ * @template N1 - string old key

/**
* RenameEffectId is the result type of renaming a key in a NameToEffectId.
* RenameEffectId is the result type of renaming a key in a {@link NameToEffectId}.
*
* @typedef {object} RenameEffectId<T extends NameToEffectId, N1 extends keyof T, N2 extends string> - the result type of { [N1]: T[N1]; } -> { [N2]: T[N1]; }
* ```ts
* RenameEffectId<{ [N1]: T[N1] }, N1, N2> -> { [N2]: T[N1] }
* ```
*
* @typedef {object} RenameEffectId
* @template T - concrete NameToEffectIds

@@ -218,5 +225,5 @@ * @template N1 - string old key

* If K does extend keyof T (K is a key of the object T), then never | Message will be the result type.
* The latter would result in a TS-error, if a function expects an argument as AssertNonExistingKey<K, T, M>, saying "argument of type <K> is not assignable to parameter of type <Message>"
* The latter would result in a TS-error, if a function expects an argument as AssertNonExistingKey\<K, T, M\>, saying "argument of type \<K\> is not assignable to parameter of type \<Message\>"
*
* @typedef {object} AssertNonExistingKey<K, T, Message> - evaluates to K only if K is not in keyof T, else gives compile-time error including Message
* @typedef {object} AssertNonExistingKey - evaluates to K only if K is not in keyof T, else gives compile-time error including Message
* @template K - string

@@ -230,3 +237,3 @@ * @template T - object with string keys

/**
* The SignalsFactory wraps a SignalsBuild<IN, OUT, CONFIG, EFF> function, allowing for simple Signals composition
* A SignalsFactory wraps a {@link SignalsBuild} function, allowing for simple {@link Signals} composition
* and manipulation.

@@ -237,6 +244,6 @@ * Via the compose method, two SignalsFactories can be easily composed to a new one.

* compose, extendSetup, mapInput, mapOutput and mapConfig).
* SignalsFactory instances are immutable, hence all methods return a new SignalsFactory instance.
* SignalsFactory instances are immutable (persistent data structures), hence all methods return a new SignalsFactory instance.
* (The whole purpose of this class is to provide immutable SignalsBuild composition)
*
* @class SignalsFactory<IN extends NameToSignalId, OUT extends NameToSignalId, CONFIG extends Configuration = {}, EFF extends NameToEffectId = {}>
* @class SignalsFactory
*/

@@ -246,5 +253,5 @@ export declare class SignalsFactory<IN extends NameToSignalId, OUT extends NameToSignalId, CONFIG extends Configuration = {}, EFF extends NameToEffectId = {}> {

/**
* The constructor takes a pure function implementing SignalsBuild<IN, OUT, CONFIG, EFF>.
* The constructor takes a pure function implementing SignalsBuild.
*
* @param {SignalsBuild<IN, OUT, CONFIG, EFF>} build - a pure function mapping from CONFIG to Signals<IN, OUT, EFF>
* @param {SignalsBuild<IN, OUT, CONFIG, EFF>} build - a pure function mapping from CONFIG to Signals
* @constructor

@@ -254,9 +261,9 @@ */

/**
* The compose method takes a second SignalsFactory<IN2, OUT2, CONFIG2, EFF2> and returns a new SignalsFactory
* that represents the composition of this SignalsFactory and the argument SignalsFactory<IN2, OUT2, CONFIG2, EFF2>.
* You can re-map the input, output, configuration and effects of the resulting ComposedFactory<IN, OUT, CONFIG, EFF, IN2, OUT2, CONFIG2, EFF2>
* The compose method takes a second SignalsFactory2 and returns a new SignalsFactory
* that represents the composition of this SignalsFactory and the argument SignalsFactory2.
* You can re-map the input, output, configuration and effects of the resulting composed SignalsFactory
* by using mapInput, mapOutput, mapConfig and mapEffects correspondingly (as well as the many other convenience methods).
*
* @param {SignalsFactory<IN2, OUT2, CONFIG2, EFF2>} factory2 - a SignalsFactory<IN2, OUT2, CONFIG2, EFF2>
* @returns {ComposedFactory<IN, OUT, CONFIG, EFF, IN2, OUT2, CONFIG2, EFF2>} - the SignalsFactory resulting from the composition of SignalsFactory<IN, OUT, CONFIG, EFF> and SignalsFactory<IN2, OUT2, CONFIG2, EFF2>
* @param {SignalsFactory} factory2 - a SignalsFactory
* @returns {SignalsFactory} - the SignalsFactory resulting from the composition of this SignalsFactory and SignalsFactory2
*/

@@ -266,9 +273,9 @@ compose<IN2 extends NameToSignalId, OUT2 extends NameToSignalId, CONFIG2 extends Configuration, EFF2 extends NameToEffectId>(factory2: SignalsFactory<IN2, OUT2, CONFIG2, EFF2>): ComposedFactory<IN, OUT, CONFIG, EFF, IN2, OUT2, CONFIG2, EFF2>;

* This method implements monadic-bind for the SignalsFactory.
* It takes as argument a pure function that implements SignalsMapToFactory<IN, OUT, CONFIG, EFF, IN2, OUT2, CONFIG2, EFF2>, hence
* a function taking SignalsBuild<IN, OUT, CONFIG, EFF> as argument and returning a SignalsFactory<IN2, OUT2, CONFIG2, EFF2>.
* The result of bind is a new SignalsFactory<IN2, OUT2, CONFIG2, EFF2> that uses the SignalsBuild<IN2, OUT2, CONFIG2, EFF2>::build
* It takes as argument a pure function that implements SignalsMapToFactory\<IN, OUT, CONFIG, EFF, IN2, OUT2, CONFIG2, EFF2\>, hence
* a function taking SignalsBuild\<IN, OUT, CONFIG, EFF\> as argument and returning a SignalsFactory\<IN2, OUT2, CONFIG2, EFF2\>.
* The result of bind is a new SignalsFactory that uses the SignalsBuild\<IN2, OUT2, CONFIG2, EFF2\>::build
* of the factory returned from the mapper (hence the result of bind is not the same instance as returned by the mapper).
*
* @param {BindMapper<IN, OUT, CONFIG, EFF, IN2, OUT2, CONFIG2, EFF2>} mapper - a pure function mapping from SignalsBuild<IN, OUT, CONFIG, EFF> to SignalsFactory<IN2, OUT2, CONFIG2, EFF2>
* @returns {SignalsFactory<IN2, OUT2, CONFIG2, EFF>} - a new SignalsFactory<IN2, OUT2, CONFIG2, EFF2>
* @param {BindMapper} mapper - a pure function mapping from SignalsBuild\<IN, OUT, CONFIG, EFF\> to SignalsFactory\<IN2, OUT2, CONFIG2, EFF2\>
* @returns {SignalsFactory} - a new SignalsFactory\<IN2, OUT2, CONFIG2, EFF2\>
*/

@@ -278,18 +285,18 @@ bind<IN2 extends NameToSignalId, OUT2 extends NameToSignalId, CONFIG2 extends Configuration, EFF2 extends NameToEffectId>(mapper: BindMapper<IN, OUT, CONFIG, EFF, IN2, OUT2, CONFIG2, EFF2>): SignalsFactory<IN2, OUT2, CONFIG2, EFF2>;

* This method implements the functor-fmap for the SignalsFactory.
* It takes as argument a pure function that implements BuildMapper<IN, OUT, CONFIG, EFF, IN2, OUT2, CONFIG2, EFF2>, hence
* a function taking SignalsBuild<IN, OUT, CONFIG, EFF> as argument and returning a SignalsBuild<IN2, OUT2, CONFIG2, EFF2>.
* The result of fmap is a new SignalsFactory<IN2, OUT2, CONFIG2, EFF2> that uses the SignalsBuild<IN2, OUT2, CONFIG2, EFF2> returned
* It takes as argument a pure function that implements BuildMapper\<IN, OUT, CONFIG, EFF, IN2, OUT2, CONFIG2, EFF2\>, hence
* a function taking SignalsBuild\<IN, OUT, CONFIG, EFF\> as argument and returning a SignalsBuild\<IN2, OUT2, CONFIG2, EFF2\>.
* The result of fmap is a new SignalsFactory that uses the SignalsBuild\<IN2, OUT2, CONFIG2, EFF2\> returned
* from the mapper.
*
* @param {BuildMapper<IN, OUT, CONFIG, EFF, IN2, OUT2, CONFIG2, EFF2>} mapper - a pure function mapping from SignalsBuild<IN, OUT, CONFIG, EFF> to SignalsBuild<IN2, OUT2, CONFIG2, EFF2>
* @returns {SignalsFactory<IN2, OUT2, CONFIG2, EFF2>} - a new SignalsFactory<IN2, OUT2, CONFIG2, EFF2>
* @param {BuildMapper} mapper - a pure function mapping from SignalsBuild\<IN, OUT, CONFIG, EFF\> to SignalsBuild\<IN2, OUT2, CONFIG2, EFF2\>
* @returns {SignalsFactory} - a new SignalsFactory\<IN2, OUT2, CONFIG2, EFF2\>
*/
fmap<IN2 extends NameToSignalId, OUT2 extends NameToSignalId, CONFIG2 extends Configuration, EFF2 extends NameToEffectId>(mapper: BuildMapper<IN, OUT, CONFIG, EFF, IN2, OUT2, CONFIG2, EFF2>): SignalsFactory<IN2, OUT2, CONFIG2, EFF2>;
/**
* The extendSetup method takes as argument a function that implements ExtendSetup<IN, OUT, CONFIG, EFF>.
* The extendSetup method takes as argument a function that implements ExtendSetup\<IN, OUT, CONFIG, EFF\>.
* It returns a new SignalsFactory of the same type as this SignalsFactory, but with a wrapped SignalsBuild that
* extends the code executed in the Signals setup method by the provided code.
*
* @param {ExtendSetup<IN, OUT, CONFIG, EFF>} extend - a function extending the setup method of the Signals produced by the SignalsBuild of the resulting SignalsFactory
* @returns {SignalsFactory<IN, OUT, CONFIG, EFF>} - a new SignalsFactory with extended store setup
* @param {ExtendSetup} extend - a function extending the setup method of the Signals produced by the SignalsBuild of the resulting SignalsFactory
* @returns {SignalsFactory} - a new SignalsFactory with extended store setup
*/

@@ -301,13 +308,13 @@ extendSetup(extend: ExtendSetup<IN, OUT, CONFIG, EFF>): SignalsFactory<IN, OUT, CONFIG, EFF>;

* If keepInputId is set to true, it returns a new SignalsFactory of the same type as this SignalsFactory,
* but with an extended setup logic, that connects the Signal<S extends T> that corresponds to the named output-id to a
* new Signal<T> corresponding to the named input-id.
* but with an extended setup logic, that connects the Signal\<S extends T\> that corresponds to the named output-id to a
* new Signal\<T\> corresponding to the named input-id.
* If keepInputId is set to false, it also extends the setup logic to connect the corresponding signal-ids, but in addition
* the specified input-id will be excluded from the IN-type of the resulting factory.
* (also see store.connect documentation, as this is used under the hood)
* Typescript will enforce that both names (keys) map to compatible signal ids, hence if KIN corresponds to SignalId<T>,
* then KOUT must correspond to SignalId<S extends T> (though one might be an EventId and the other a BehaviorId).
* Typescript will enforce that both names (keys) map to compatible signal ids, hence if KIN corresponds to SignalId\<T\>,
* then KOUT must correspond to SignalId\<S extends T\> (though one might be an EventId and the other a BehaviorId).
* That is, even though you only use strings as arguments, this method is still type-safe and will not compile if you try to specify names of non-existing or incompatible ids.
*
* @param {KIN} inputName - a key of IN, where IN[toName] must be of type Signal<T>
* @param {KOUT} outputName - a key of OUT, where OUT[outputName] must be of type Signal<S extends T>
* @param {KIN} inputName - a key of IN, where IN\[toName\] must be of type Signal\<T\>
* @param {KOUT} outputName - a key of OUT, where OUT\[outputName\] must be of type Signal\<S extends T\>
* @param {boolean} keepInputId - if set to false, the input-id corresponding to toName will be removed from the resulting factories' IN

@@ -322,4 +329,4 @@ * @returns {SignalsFactory} - a new SignalsFactory with the concrete type depending on the keepInputId argument

*
* @param {KIN} inputName - a key of IN, where IN[toName] must be of type Signal<T>
* @param {ID} fromId - a Signal<S extends T>
* @param {KIN} inputName - a key of IN, where IN\[toName\] must be of type Signal\<T\>
* @param {ID} fromId - a Signal\<S extends T\>
* @param {boolean} keepInputId - if set to false, the input-id corresponding to toName will be removed from the resulting factories' IN

@@ -334,4 +341,4 @@ * @returns {SignalsFactory} - a new SignalsFactory with the concrete type depending on the keepInputId argument

*
* @param {KIN} inputName - a key of IN, where IN[toName] must be of type Signal<T>
* @param {function} sourceGetter - a function returning an Observable<S extends T>
* @param {KIN} inputName - a key of IN, where IN\[toName\] must be of type Signal\<T\>
* @param {function} sourceGetter - a function returning an Observable\<S extends T\>
* @param {boolean} keepInputId - if set to false, the input-id corresponding to toName will be removed from the resulting factories' IN

@@ -342,15 +349,15 @@ * @returns {SignalsFactory} - a new SignalsFactory with the concrete type depending on the keepInputId argument

/**
* The mapConfig method takes as argument a pure function that implements MapConfig<CONFIG, CONFIG2>.
* It returns a new SignalsFactory<IN, OUT, CONFIG2, EFF>.
* The mapConfig method takes as argument a pure function that implements MapConfig\<CONFIG, CONFIG2\>.
* It returns a new SignalsFactory\<IN, OUT, CONFIG2, EFF\>.
*
* @param {MapConfig<CONFIG, CONFIG2>} mapper - a pure function mapping CONFIG2 to CONFIG
* @returns {SignalsFactory<IN, OUT, CONFIG2, EFF>} - a new SignalsFactory with different Configuration type
* @param {MapConfig} mapper - a pure function mapping CONFIG2 to CONFIG
* @returns {SignalsFactory} - a new SignalsFactory with different Configuration type
*/
mapConfig<CONFIG2 extends Configuration>(mapper: MapConfig<CONFIG, CONFIG2>): SignalsFactory<IN, OUT, CONFIG2, EFF>;
/**
* The mapInput method takes as argument a pure function that implements MapSignalIds<IN, IN2>.
* It returns a new SignalsFactory<IN2, OUT, CONFIG, EFF>.
* The mapInput method takes as argument a pure function that implements MapSignalIds\<IN, IN2\>.
* It returns a new SignalsFactory\<IN2, OUT, CONFIG, EFF\>.
*
* @param {MapSignalIds<IN, IN2, CONFIG>} mapper - a pure function mapping from IN to IN2
* @returns {SignalsFactory<IN2, OUT, CONFIG, EFF>} - a new SignalsFactory with different input signals
* @param {MapSignalIds} mapper - a pure function mapping from IN to IN2
* @returns {SignalsFactory} - a new SignalsFactory with different input signals
*/

@@ -365,4 +372,4 @@ mapInput<IN2 extends NameToSignalId>(mapper: MapSignalIds<IN, IN2, CONFIG>): SignalsFactory<IN2, OUT, CONFIG, EFF>;

* @param {K} name - the name of the new SignalId
* @param {() => ID} idGetter - a function returning the new SignalId
* @returns {SignalsFactory<AddSignalId<IN, K, ID>, OUT, CONFIG, EFF>} - a new SignalsFactory with modified input signals
* @param {function} idGetter - a function returning the new SignalId
* @returns {SignalsFactory} - a new SignalsFactory with modified input signals
*/

@@ -375,6 +382,6 @@ addInputId<K extends string, ID extends SignalId<any>>(name: AssertNonExistingKey<K, IN, 'any name not in keyof IN'>, idGetter: (config: CONFIG) => ID): SignalsFactory<AddSignalId<IN, K, ID>, OUT, CONFIG, EFF>;

* @template K1 - a concrete key of IN
* @template K2 - the new name for IN[K1]
* @template K2 - the new name for IN\[K1\]
* @param {K1} oldName - the old key
* @param {K2} newName - the new key
* @returns {SignalsFactory<RenameId<IN, K1, K2>, OUT, CONFIG, EFF>} - a new SignalsFactory with modified input signals
* @returns {SignalsFactory} - a new SignalsFactory with modified input signals
*/

@@ -388,11 +395,11 @@ renameInputId<K1 extends keyof IN, K2 extends string>(oldName: K1, newName: K2): SignalsFactory<RenameId<IN, K1, K2>, OUT, CONFIG, EFF>;

* @param {K} name - the name of the SignalId to be removed
* @returns {SignalsFactory<Omit<IN, K>, OUT, CONFIG, EFF>} - a new SignalsFactory with modified input signals
* @returns {SignalsFactory} - a new SignalsFactory with modified input signals
*/
removeInputId<K extends keyof IN>(name: K): SignalsFactory<Omit<IN, K>, OUT, CONFIG, EFF>;
/**
* The mapOutput method takes as argument a pure function that implements MapSignalIds<OUT, OUT2>.
* It returns a new SignalsFactory<IN, OUT2, CONFIG, EFF>.
* The mapOutput method takes as argument a pure function that implements MapSignalIds\<OUT, OUT2\>.
* It returns a new SignalsFactory\<IN, OUT2, CONFIG, EFF\>.
*
* @param {MapSignalIds<OUT, OUT2>} mapper - a pure function mapping from OUT to OUT2
* @returns {SignalsFactory<IN, OUT2, CONFIG, EFF>} - a new SignalsFactory with different output signals
* @param {MapSignalIds} mapper - a pure function mapping from OUT to OUT2
* @returns {SignalsFactory} - a new SignalsFactory with different output signals
*/

@@ -407,4 +414,4 @@ mapOutput<OUT2 extends NameToSignalId>(mapper: MapSignalIds<OUT, OUT2, CONFIG>): SignalsFactory<IN, OUT2, CONFIG, EFF>;

* @param {K} name - the name of the new SignalId
* @param {() => ID} idGetter - a function returning the new SignalId
* @returns {SignalsFactory<IN, AddOrReplaceId<OUT, K, ID>, CONFIG, EFF>} - a new SignalsFactory with modified output signals
* @param {function} idGetter - a function returning the new SignalId
* @returns {SignalsFactory} - a new SignalsFactory with modified output signals
*/

@@ -417,6 +424,6 @@ addOutputId<K extends string, ID extends SignalId<any>>(name: AssertNonExistingKey<K, OUT, 'any name not in keyof OUT'>, idGetter: (config: CONFIG) => ID): SignalsFactory<IN, AddSignalId<OUT, K, ID>, CONFIG, EFF>;

* @template K1 - a concrete key of OUT
* @template K2 - the new name for OUT[K1]
* @template K2 - the new name for OUT\[K1\]
* @param {K1} oldName - the old key
* @param {K2} newName - the new key
* @returns {SignalsFactory<IN, RenameId<OUT, K1, K2>, CONFIG, EFF>} - a new SignalsFactory with modified output signals
* @returns {SignalsFactory} - a new SignalsFactory with modified output signals
*/

@@ -430,3 +437,3 @@ renameOutputId<K1 extends keyof OUT, K2 extends string>(oldName: K1, newName: K2): SignalsFactory<IN, RenameId<OUT, K1, K2>, CONFIG, EFF>;

* @param {K} name - the name of the SignalId to be removed
* @returns {SignalsFactory<IN, Omit<OUT, K>, CONFIG, EFF>} - a new SignalsFactory with modified output signals
* @returns {SignalsFactory} - a new SignalsFactory with modified output signals
*/

@@ -439,18 +446,18 @@ removeOutputId<K extends keyof OUT>(name: K): SignalsFactory<IN, Omit<OUT, K>, CONFIG, EFF>;

* new behavior into output under the removed name of the existing behavior.
* Hence, this transforms from SignalsFactory<IN, OUT, CONFIG> to SignalsFactory<IN, OUT2, CONFIG>
* with OUT2 having the same keys as OUT, but OUT2[KOUT] having type TNEW and OUT[KOUT] having type TOLD
* Hence, this transforms from SignalsFactory\<IN, OUT, CONFIG\> to SignalsFactory\<IN, OUT2, CONFIG\>
* with OUT2 having the same keys as OUT, but OUT2\[KOUT\] having type TNEW and OUT\[KOUT\] having type TOLD
*
* @template KOUT - a concrete output key mapping to a BehaviorId<any>
* @template TNEW - value-type of the OUT2[KOUT] BehaviorId after mapping
* @param {KOUT} outputName - the name of a BehaviorId<any> from OUT
* @param {function} mapper - a function returning Observable<TNEW>
* @returns {SignalsFactory<IN, AddOrReplaceId<OUT, KOUT, BehaviorId<TNEW>>, CONFIG, EFF>} - a new SignalsFactory with a modified output signal
* @template TNEW - value-type of the OUT2\[KOUT\] BehaviorId after mapping
* @param {KOUT} outputName - the name of a BehaviorId\<any\> from OUT
* @param {function} mapper - a function returning Observable\<TNEW\>
* @returns {SignalsFactory} - a new SignalsFactory with a modified output signal
*/
mapOutputBehavior<TNEW, KOUT extends keyof WithValueType<OUT, BehaviorId<any>>>(outputName: KOUT, mapper: (old: Observable<ToBehaviorIdValueType<OUT[KOUT]>>, store: Store, input: IN, output: OUT, config: CONFIG) => Observable<TNEW>): SignalsFactory<IN, AddOrReplaceId<OUT, KOUT, DerivedId<TNEW>>, CONFIG, EFF>;
/**
* The mapEffects method takes as argument a pure function that implements MapEffectIds<EFF, EFF2, CONFIG>.
* It returns a new SignalsFactory<IN, OUT, CONFIG, EFF2>.
* The mapEffects method takes as argument a pure function that implements MapEffectIds\<EFF, EFF2, CONFIG\>.
* It returns a new SignalsFactory\<IN, OUT, CONFIG, EFF2\>.
*
* @param {MapSignalIds<EFF, EFF2>} mapper - a pure function mapping from EFF to EFF2
* @returns {SignalsFactory<IN, OUT, CONFIG, EFF2>} - a new SignalsFactory with different effect-ids
* @param {MapSignalIds} mapper - a pure function mapping from EFF to EFF2
* @returns {SignalsFactory} - a new SignalsFactory with different effect-ids
*/

@@ -465,4 +472,4 @@ mapEffects<EFF2 extends NameToEffectId>(mapper: MapEffectIds<EFF, EFF2, CONFIG>): SignalsFactory<IN, OUT, CONFIG, EFF2>;

* @param {K} name - the name of the new EffectId
* @param {() => ID} idGetter - a function returning the new EffectId
* @returns {SignalsFactory<IN, OUT, CONFIG, AddEffectId<EFF, K, ID>>} - a new SignalsFactory with modified effect-ids
* @param {function} idGetter - a function returning the new EffectId
* @returns {SignalsFactory} - a new SignalsFactory with modified effect-ids
*/

@@ -476,3 +483,3 @@ addEffectId<K extends string, ID extends EffectId<any, any>>(name: AssertNonExistingKey<K, EFF, 'any name not in keyof EFF'>, idGetter: (config: CONFIG) => ID): SignalsFactory<IN, OUT, CONFIG, AddEffectId<EFF, K, ID>>;

* @param {K} name - the name of in NameToEffectIds to be removed
* @returns {SignalsFactory<IN, OUT, CONFIG, Omit<EFF, K>>} - a new SignalsFactory with modified effect-ids
* @returns {SignalsFactory} - a new SignalsFactory with modified effect-ids
*/

@@ -499,5 +506,5 @@ removeEffectId<K extends keyof EFF>(name: K): SignalsFactory<IN, OUT, CONFIG, Omit<EFF, K>>;

* @param {K2} newName - the new key
* @returns {SignalsFactory<IN, OUT, CONFIG, RenameEffectId<EFF, K1, K2>>} - a new SignalsFactory with modified effect-ids
* @returns {SignalsFactory} - a new SignalsFactory with modified effect-ids
*/
renameEffectId<K1 extends keyof EFF, K2 extends string>(oldName: K1, newName: K2): SignalsFactory<IN, OUT, CONFIG, RenameEffectId<EFF, K1, K2>>;
}

@@ -17,3 +17,3 @@ var __rest = (this && this.__rest) || function (s, e) {

/**
* The SignalsFactory wraps a SignalsBuild<IN, OUT, CONFIG, EFF> function, allowing for simple Signals composition
* A SignalsFactory wraps a {@link SignalsBuild} function, allowing for simple {@link Signals} composition
* and manipulation.

@@ -24,12 +24,12 @@ * Via the compose method, two SignalsFactories can be easily composed to a new one.

* compose, extendSetup, mapInput, mapOutput and mapConfig).
* SignalsFactory instances are immutable, hence all methods return a new SignalsFactory instance.
* SignalsFactory instances are immutable (persistent data structures), hence all methods return a new SignalsFactory instance.
* (The whole purpose of this class is to provide immutable SignalsBuild composition)
*
* @class SignalsFactory<IN extends NameToSignalId, OUT extends NameToSignalId, CONFIG extends Configuration = {}, EFF extends NameToEffectId = {}>
* @class SignalsFactory
*/
export class SignalsFactory {
/**
* The constructor takes a pure function implementing SignalsBuild<IN, OUT, CONFIG, EFF>.
* The constructor takes a pure function implementing SignalsBuild.
*
* @param {SignalsBuild<IN, OUT, CONFIG, EFF>} build - a pure function mapping from CONFIG to Signals<IN, OUT, EFF>
* @param {SignalsBuild<IN, OUT, CONFIG, EFF>} build - a pure function mapping from CONFIG to Signals
* @constructor

@@ -41,9 +41,9 @@ */

/**
* The compose method takes a second SignalsFactory<IN2, OUT2, CONFIG2, EFF2> and returns a new SignalsFactory
* that represents the composition of this SignalsFactory and the argument SignalsFactory<IN2, OUT2, CONFIG2, EFF2>.
* You can re-map the input, output, configuration and effects of the resulting ComposedFactory<IN, OUT, CONFIG, EFF, IN2, OUT2, CONFIG2, EFF2>
* The compose method takes a second SignalsFactory2 and returns a new SignalsFactory
* that represents the composition of this SignalsFactory and the argument SignalsFactory2.
* You can re-map the input, output, configuration and effects of the resulting composed SignalsFactory
* by using mapInput, mapOutput, mapConfig and mapEffects correspondingly (as well as the many other convenience methods).
*
* @param {SignalsFactory<IN2, OUT2, CONFIG2, EFF2>} factory2 - a SignalsFactory<IN2, OUT2, CONFIG2, EFF2>
* @returns {ComposedFactory<IN, OUT, CONFIG, EFF, IN2, OUT2, CONFIG2, EFF2>} - the SignalsFactory resulting from the composition of SignalsFactory<IN, OUT, CONFIG, EFF> and SignalsFactory<IN2, OUT2, CONFIG2, EFF2>
* @param {SignalsFactory} factory2 - a SignalsFactory
* @returns {SignalsFactory} - the SignalsFactory resulting from the composition of this SignalsFactory and SignalsFactory2
*/

@@ -69,9 +69,9 @@ compose(factory2) {

* This method implements monadic-bind for the SignalsFactory.
* It takes as argument a pure function that implements SignalsMapToFactory<IN, OUT, CONFIG, EFF, IN2, OUT2, CONFIG2, EFF2>, hence
* a function taking SignalsBuild<IN, OUT, CONFIG, EFF> as argument and returning a SignalsFactory<IN2, OUT2, CONFIG2, EFF2>.
* The result of bind is a new SignalsFactory<IN2, OUT2, CONFIG2, EFF2> that uses the SignalsBuild<IN2, OUT2, CONFIG2, EFF2>::build
* It takes as argument a pure function that implements SignalsMapToFactory\<IN, OUT, CONFIG, EFF, IN2, OUT2, CONFIG2, EFF2\>, hence
* a function taking SignalsBuild\<IN, OUT, CONFIG, EFF\> as argument and returning a SignalsFactory\<IN2, OUT2, CONFIG2, EFF2\>.
* The result of bind is a new SignalsFactory that uses the SignalsBuild\<IN2, OUT2, CONFIG2, EFF2\>::build
* of the factory returned from the mapper (hence the result of bind is not the same instance as returned by the mapper).
*
* @param {BindMapper<IN, OUT, CONFIG, EFF, IN2, OUT2, CONFIG2, EFF2>} mapper - a pure function mapping from SignalsBuild<IN, OUT, CONFIG, EFF> to SignalsFactory<IN2, OUT2, CONFIG2, EFF2>
* @returns {SignalsFactory<IN2, OUT2, CONFIG2, EFF>} - a new SignalsFactory<IN2, OUT2, CONFIG2, EFF2>
* @param {BindMapper} mapper - a pure function mapping from SignalsBuild\<IN, OUT, CONFIG, EFF\> to SignalsFactory\<IN2, OUT2, CONFIG2, EFF2\>
* @returns {SignalsFactory} - a new SignalsFactory\<IN2, OUT2, CONFIG2, EFF2\>
*/

@@ -84,9 +84,9 @@ bind(mapper) {

* This method implements the functor-fmap for the SignalsFactory.
* It takes as argument a pure function that implements BuildMapper<IN, OUT, CONFIG, EFF, IN2, OUT2, CONFIG2, EFF2>, hence
* a function taking SignalsBuild<IN, OUT, CONFIG, EFF> as argument and returning a SignalsBuild<IN2, OUT2, CONFIG2, EFF2>.
* The result of fmap is a new SignalsFactory<IN2, OUT2, CONFIG2, EFF2> that uses the SignalsBuild<IN2, OUT2, CONFIG2, EFF2> returned
* It takes as argument a pure function that implements BuildMapper\<IN, OUT, CONFIG, EFF, IN2, OUT2, CONFIG2, EFF2\>, hence
* a function taking SignalsBuild\<IN, OUT, CONFIG, EFF\> as argument and returning a SignalsBuild\<IN2, OUT2, CONFIG2, EFF2\>.
* The result of fmap is a new SignalsFactory that uses the SignalsBuild\<IN2, OUT2, CONFIG2, EFF2\> returned
* from the mapper.
*
* @param {BuildMapper<IN, OUT, CONFIG, EFF, IN2, OUT2, CONFIG2, EFF2>} mapper - a pure function mapping from SignalsBuild<IN, OUT, CONFIG, EFF> to SignalsBuild<IN2, OUT2, CONFIG2, EFF2>
* @returns {SignalsFactory<IN2, OUT2, CONFIG2, EFF2>} - a new SignalsFactory<IN2, OUT2, CONFIG2, EFF2>
* @param {BuildMapper} mapper - a pure function mapping from SignalsBuild\<IN, OUT, CONFIG, EFF\> to SignalsBuild\<IN2, OUT2, CONFIG2, EFF2\>
* @returns {SignalsFactory} - a new SignalsFactory\<IN2, OUT2, CONFIG2, EFF2\>
*/

@@ -98,8 +98,8 @@ fmap(mapper) {

/**
* The extendSetup method takes as argument a function that implements ExtendSetup<IN, OUT, CONFIG, EFF>.
* The extendSetup method takes as argument a function that implements ExtendSetup\<IN, OUT, CONFIG, EFF\>.
* It returns a new SignalsFactory of the same type as this SignalsFactory, but with a wrapped SignalsBuild that
* extends the code executed in the Signals setup method by the provided code.
*
* @param {ExtendSetup<IN, OUT, CONFIG, EFF>} extend - a function extending the setup method of the Signals produced by the SignalsBuild of the resulting SignalsFactory
* @returns {SignalsFactory<IN, OUT, CONFIG, EFF>} - a new SignalsFactory with extended store setup
* @param {ExtendSetup} extend - a function extending the setup method of the Signals produced by the SignalsBuild of the resulting SignalsFactory
* @returns {SignalsFactory} - a new SignalsFactory with extended store setup
*/

@@ -119,13 +119,13 @@ extendSetup(extend) {

* If keepInputId is set to true, it returns a new SignalsFactory of the same type as this SignalsFactory,
* but with an extended setup logic, that connects the Signal<S extends T> that corresponds to the named output-id to a
* new Signal<T> corresponding to the named input-id.
* but with an extended setup logic, that connects the Signal\<S extends T\> that corresponds to the named output-id to a
* new Signal\<T\> corresponding to the named input-id.
* If keepInputId is set to false, it also extends the setup logic to connect the corresponding signal-ids, but in addition
* the specified input-id will be excluded from the IN-type of the resulting factory.
* (also see store.connect documentation, as this is used under the hood)
* Typescript will enforce that both names (keys) map to compatible signal ids, hence if KIN corresponds to SignalId<T>,
* then KOUT must correspond to SignalId<S extends T> (though one might be an EventId and the other a BehaviorId).
* Typescript will enforce that both names (keys) map to compatible signal ids, hence if KIN corresponds to SignalId\<T\>,
* then KOUT must correspond to SignalId\<S extends T\> (though one might be an EventId and the other a BehaviorId).
* That is, even though you only use strings as arguments, this method is still type-safe and will not compile if you try to specify names of non-existing or incompatible ids.
*
* @param {KIN} inputName - a key of IN, where IN[toName] must be of type Signal<T>
* @param {KOUT} outputName - a key of OUT, where OUT[outputName] must be of type Signal<S extends T>
* @param {KIN} inputName - a key of IN, where IN\[toName\] must be of type Signal\<T\>
* @param {KOUT} outputName - a key of OUT, where OUT\[outputName\] must be of type Signal\<S extends T\>
* @param {boolean} keepInputId - if set to false, the input-id corresponding to toName will be removed from the resulting factories' IN

@@ -148,4 +148,4 @@ * @returns {SignalsFactory} - a new SignalsFactory with the concrete type depending on the keepInputId argument

*
* @param {KIN} inputName - a key of IN, where IN[toName] must be of type Signal<T>
* @param {ID} fromId - a Signal<S extends T>
* @param {KIN} inputName - a key of IN, where IN\[toName\] must be of type Signal\<T\>
* @param {ID} fromId - a Signal\<S extends T\>
* @param {boolean} keepInputId - if set to false, the input-id corresponding to toName will be removed from the resulting factories' IN

@@ -167,4 +167,4 @@ * @returns {SignalsFactory} - a new SignalsFactory with the concrete type depending on the keepInputId argument

*
* @param {KIN} inputName - a key of IN, where IN[toName] must be of type Signal<T>
* @param {function} sourceGetter - a function returning an Observable<S extends T>
* @param {KIN} inputName - a key of IN, where IN\[toName\] must be of type Signal\<T\>
* @param {function} sourceGetter - a function returning an Observable\<S extends T\>
* @param {boolean} keepInputId - if set to false, the input-id corresponding to toName will be removed from the resulting factories' IN

@@ -182,7 +182,7 @@ * @returns {SignalsFactory} - a new SignalsFactory with the concrete type depending on the keepInputId argument

/**
* The mapConfig method takes as argument a pure function that implements MapConfig<CONFIG, CONFIG2>.
* It returns a new SignalsFactory<IN, OUT, CONFIG2, EFF>.
* The mapConfig method takes as argument a pure function that implements MapConfig\<CONFIG, CONFIG2\>.
* It returns a new SignalsFactory\<IN, OUT, CONFIG2, EFF\>.
*
* @param {MapConfig<CONFIG, CONFIG2>} mapper - a pure function mapping CONFIG2 to CONFIG
* @returns {SignalsFactory<IN, OUT, CONFIG2, EFF>} - a new SignalsFactory with different Configuration type
* @param {MapConfig} mapper - a pure function mapping CONFIG2 to CONFIG
* @returns {SignalsFactory} - a new SignalsFactory with different Configuration type
*/

@@ -194,7 +194,7 @@ mapConfig(mapper) {

/**
* The mapInput method takes as argument a pure function that implements MapSignalIds<IN, IN2>.
* It returns a new SignalsFactory<IN2, OUT, CONFIG, EFF>.
* The mapInput method takes as argument a pure function that implements MapSignalIds\<IN, IN2\>.
* It returns a new SignalsFactory\<IN2, OUT, CONFIG, EFF\>.
*
* @param {MapSignalIds<IN, IN2, CONFIG>} mapper - a pure function mapping from IN to IN2
* @returns {SignalsFactory<IN2, OUT, CONFIG, EFF>} - a new SignalsFactory with different input signals
* @param {MapSignalIds} mapper - a pure function mapping from IN to IN2
* @returns {SignalsFactory} - a new SignalsFactory with different input signals
*/

@@ -214,4 +214,4 @@ mapInput(mapper) {

* @param {K} name - the name of the new SignalId
* @param {() => ID} idGetter - a function returning the new SignalId
* @returns {SignalsFactory<AddSignalId<IN, K, ID>, OUT, CONFIG, EFF>} - a new SignalsFactory with modified input signals
* @param {function} idGetter - a function returning the new SignalId
* @returns {SignalsFactory} - a new SignalsFactory with modified input signals
*/

@@ -226,6 +226,6 @@ addInputId(name, idGetter) {

* @template K1 - a concrete key of IN
* @template K2 - the new name for IN[K1]
* @template K2 - the new name for IN\[K1\]
* @param {K1} oldName - the old key
* @param {K2} newName - the new key
* @returns {SignalsFactory<RenameId<IN, K1, K2>, OUT, CONFIG, EFF>} - a new SignalsFactory with modified input signals
* @returns {SignalsFactory} - a new SignalsFactory with modified input signals
*/

@@ -245,3 +245,3 @@ renameInputId(oldName, newName) {

* @param {K} name - the name of the SignalId to be removed
* @returns {SignalsFactory<Omit<IN, K>, OUT, CONFIG, EFF>} - a new SignalsFactory with modified input signals
* @returns {SignalsFactory} - a new SignalsFactory with modified input signals
*/

@@ -256,7 +256,7 @@ removeInputId(name) {

/**
* The mapOutput method takes as argument a pure function that implements MapSignalIds<OUT, OUT2>.
* It returns a new SignalsFactory<IN, OUT2, CONFIG, EFF>.
* The mapOutput method takes as argument a pure function that implements MapSignalIds\<OUT, OUT2\>.
* It returns a new SignalsFactory\<IN, OUT2, CONFIG, EFF\>.
*
* @param {MapSignalIds<OUT, OUT2>} mapper - a pure function mapping from OUT to OUT2
* @returns {SignalsFactory<IN, OUT2, CONFIG, EFF>} - a new SignalsFactory with different output signals
* @param {MapSignalIds} mapper - a pure function mapping from OUT to OUT2
* @returns {SignalsFactory} - a new SignalsFactory with different output signals
*/

@@ -276,4 +276,4 @@ mapOutput(mapper) {

* @param {K} name - the name of the new SignalId
* @param {() => ID} idGetter - a function returning the new SignalId
* @returns {SignalsFactory<IN, AddOrReplaceId<OUT, K, ID>, CONFIG, EFF>} - a new SignalsFactory with modified output signals
* @param {function} idGetter - a function returning the new SignalId
* @returns {SignalsFactory} - a new SignalsFactory with modified output signals
*/

@@ -288,6 +288,6 @@ addOutputId(name, idGetter) {

* @template K1 - a concrete key of OUT
* @template K2 - the new name for OUT[K1]
* @template K2 - the new name for OUT\[K1\]
* @param {K1} oldName - the old key
* @param {K2} newName - the new key
* @returns {SignalsFactory<IN, RenameId<OUT, K1, K2>, CONFIG, EFF>} - a new SignalsFactory with modified output signals
* @returns {SignalsFactory} - a new SignalsFactory with modified output signals
*/

@@ -307,3 +307,3 @@ renameOutputId(oldName, newName) {

* @param {K} name - the name of the SignalId to be removed
* @returns {SignalsFactory<IN, Omit<OUT, K>, CONFIG, EFF>} - a new SignalsFactory with modified output signals
* @returns {SignalsFactory} - a new SignalsFactory with modified output signals
*/

@@ -322,10 +322,10 @@ removeOutputId(name) {

* new behavior into output under the removed name of the existing behavior.
* Hence, this transforms from SignalsFactory<IN, OUT, CONFIG> to SignalsFactory<IN, OUT2, CONFIG>
* with OUT2 having the same keys as OUT, but OUT2[KOUT] having type TNEW and OUT[KOUT] having type TOLD
* Hence, this transforms from SignalsFactory\<IN, OUT, CONFIG\> to SignalsFactory\<IN, OUT2, CONFIG\>
* with OUT2 having the same keys as OUT, but OUT2\[KOUT\] having type TNEW and OUT\[KOUT\] having type TOLD
*
* @template KOUT - a concrete output key mapping to a BehaviorId<any>
* @template TNEW - value-type of the OUT2[KOUT] BehaviorId after mapping
* @param {KOUT} outputName - the name of a BehaviorId<any> from OUT
* @param {function} mapper - a function returning Observable<TNEW>
* @returns {SignalsFactory<IN, AddOrReplaceId<OUT, KOUT, BehaviorId<TNEW>>, CONFIG, EFF>} - a new SignalsFactory with a modified output signal
* @template TNEW - value-type of the OUT2\[KOUT\] BehaviorId after mapping
* @param {KOUT} outputName - the name of a BehaviorId\<any\> from OUT
* @param {function} mapper - a function returning Observable\<TNEW\>
* @returns {SignalsFactory} - a new SignalsFactory with a modified output signal
*/

@@ -344,7 +344,7 @@ mapOutputBehavior(outputName, mapper) {

/**
* The mapEffects method takes as argument a pure function that implements MapEffectIds<EFF, EFF2, CONFIG>.
* It returns a new SignalsFactory<IN, OUT, CONFIG, EFF2>.
* The mapEffects method takes as argument a pure function that implements MapEffectIds\<EFF, EFF2, CONFIG\>.
* It returns a new SignalsFactory\<IN, OUT, CONFIG, EFF2\>.
*
* @param {MapSignalIds<EFF, EFF2>} mapper - a pure function mapping from EFF to EFF2
* @returns {SignalsFactory<IN, OUT, CONFIG, EFF2>} - a new SignalsFactory with different effect-ids
* @param {MapSignalIds} mapper - a pure function mapping from EFF to EFF2
* @returns {SignalsFactory} - a new SignalsFactory with different effect-ids
*/

@@ -364,4 +364,4 @@ mapEffects(mapper) {

* @param {K} name - the name of the new EffectId
* @param {() => ID} idGetter - a function returning the new EffectId
* @returns {SignalsFactory<IN, OUT, CONFIG, AddEffectId<EFF, K, ID>>} - a new SignalsFactory with modified effect-ids
* @param {function} idGetter - a function returning the new EffectId
* @returns {SignalsFactory} - a new SignalsFactory with modified effect-ids
*/

@@ -377,3 +377,3 @@ addEffectId(name, idGetter) {

* @param {K} name - the name of in NameToEffectIds to be removed
* @returns {SignalsFactory<IN, OUT, CONFIG, Omit<EFF, K>>} - a new SignalsFactory with modified effect-ids
* @returns {SignalsFactory} - a new SignalsFactory with modified effect-ids
*/

@@ -416,3 +416,3 @@ removeEffectId(name) {

* @param {K2} newName - the new key
* @returns {SignalsFactory<IN, OUT, CONFIG, RenameEffectId<EFF, K1, K2>>} - a new SignalsFactory with modified effect-ids
* @returns {SignalsFactory} - a new SignalsFactory with modified effect-ids
*/

@@ -419,0 +419,0 @@ renameEffectId(oldName, newName) {

@@ -1,18 +0,1 @@

import { Observable, Subject } from 'rxjs';
import { ContextHandle } from './context-handle';
export declare class SourceObservable<T> {
private readonly sourceId;
private readonly sourceObservable;
private readonly lazySubscription;
private readonly initialValueOrValueGetter;
private subscription;
private subscriptionPending;
private initialValueDispatched;
constructor(sourceId: symbol, sourceObservable: Observable<T>, lazySubscription: boolean, initialValueOrValueGetter?: T | (() => T) | symbol);
getId(): symbol;
isLazySubscription(): boolean;
resetInitialValueDispatched(): void;
subscribeIfNecessary(contextHandle: ContextHandle, targetSubject: Subject<T>, targetObservable: Observable<T>, isTargetSubscribed: boolean, error: (error: any) => void, complete: () => void): void;
unsubscribe(): void;
}
export default SourceObservable;
import { NO_VALUE } from './store-utils';
/**
* @internal
*/
export class SourceObservable {

@@ -3,0 +6,0 @@ constructor(sourceId, sourceObservable, lazySubscription, initialValueOrValueGetter = NO_VALUE) {

import { Observable } from 'rxjs';
/**
* The rx-signals Store uses this type to uniquely identify behaviors representing a root-state behavior.
* A StateId<T> does not make any use of the generic T itself, but is given this
* The rx-signals {@link Store} uses this type to uniquely identify behaviors representing a root-state behavior.
* A StateId\<T\> does not make any use of the generic T itself, but is given this
* parameter only as a trick to let Typescript infer and thus enforce the correct types.
* Use the getStateId<T>() function to generate a corresponding ID.
* Use the {@link getStateId} function to generate a corresponding ID.
*
* @typedef {object} StateId<T> - type to uniquely identify a certain root-state behavior
* @template T - specifies the type for the corresponding behavior observable
* @property {symbol} symbol - a symbol, making the StateId unique
* @template T - specifies the value-type for the corresponding behavior observable (type of the state)
*/

@@ -16,10 +14,8 @@ export declare type StateId<T> = symbol & {

/**
* The rx-signals Store uses this type to uniquely identify behaviors representing a derived-state behavior.
* A StateId<T> does not make any use of the generic T itself, but is given this
* The rx-signals {@link Store} uses this type to uniquely identify behaviors representing a derived-state behavior.
* A StateId\<T\> does not make any use of the generic T itself, but is given this
* parameter only as a trick to let Typescript infer and thus enforce the correct types.
* Use the getDerivedId<T>() function to generate a corresponding ID.
* Use the {@link getDerivedId} function to generate a corresponding ID.
*
* @typedef {object} DerivedId<T> - type to uniquely identify a certain derived-state behavior
* @template T - specifies the type for the corresponding behavior observable
* @property {symbol} symbol - a symbol, making the DerivedId unique
* @template T - specifies the value-type for the corresponding behavior observable
*/

@@ -30,17 +26,14 @@ export declare type DerivedId<T> = symbol & {

/**
* The rx-signals Store uses this type for cases where either a StateId or a DerivedId is expected.
* The rx-signals {@link Store} uses this type for cases where either a {@link StateId} or a {@link DerivedId} is expected.
*
* @typedef {object} BehaviorId<T> - type to uniquely identify a certain behavior
* @template T - specifies the type for the corresponding behavior observable
* @template T - specifies the value-type for the corresponding behavior observable
*/
export declare type BehaviorId<T> = StateId<T> | DerivedId<T>;
/**
* The rx-signals Store uses this type to uniquely identify all of its events.
* An EventId<T> does not make any use of the generic T itself, but is given this
* The rx-signals {@link Store} uses this type to uniquely identify all of its events.
* An EventId\<T\> does not make any use of the generic T itself, but is given this
* parameter only as a trick to let Typescript infer and thus enforce the correct types.
* Use the getEventId<T>() function to generate a corresponding ID.
* Use the {@link getEventId} function to generate a corresponding ID.
*
* @typedef {object} EventId<T> - type to uniquely identify a certain event
* @template T - specifies the type for the corresponding event observable
* @property {symbol} symbol - a symbol, making the EventId unique
* @template T - specifies the value-type for the corresponding event observable
*/

@@ -51,67 +44,71 @@ export declare type EventId<T> = symbol & {

/**
* SignalId<T> is the union type of BehaviorId<T> and EventId<T>, hence it
* SignalId\<T\> is the union type of BehaviorId\<T\> and EventId\<T\>, hence it
* represents an identifier that corresponds either to a behavior or to an event.
* You can use the functions isBehaviorId or isEventId to check the concrete
* You can use the functions {@link isBehaviorId} or {@link isEventId} to check the concrete
* type of a SignalId.
*
* @typedef {object} EventId<T> - type to uniquely identify a certain event
* @template T - specifies the type for the corresponding event observable
* @template T - specifies the value-type for the corresponding observable
*/
export declare type SignalId<T> = BehaviorId<T> | EventId<T>;
/**
* ToSignalId<S> is a utility type that equals Signal<T>, if S extends SignalId<T>, else never.
* Examples:
* ToSignalId<BehaviorId<number>> would be SignalId<number>
* ToSignalId<EventId<string>> would be SignalId<string>
* ToSignalId<number> would be never
* ToSignalId\<S\> is a utility type that equals Signal\<T\>, if S extends SignalId\<T\>, else never.
*
* @typedef {object} SignalId<T> | never - the resulting type
* ```ts
* ToSignalId<BehaviorId<number>> = SignalId<number>
* ToSignalId<EventId<string>> = SignalId<string>
* ToSignalId<number> = never
* ```
*
* @template S - the generic argument to ToSignalId
* @template T - the inferred generic parameter of S, if S extends SignalId<T>
* @template T - the inferred generic parameter of S, if S extends SignalId\<T\>
*/
export declare type ToSignalId<S> = S extends SignalId<infer T> ? SignalId<T> : never;
/**
* ToBehaviorIdValueType<B> is a utility type that equals T, if B extends BehaviorId<T>, else never.
* Examples:
* ToBehaviorIdValueType<BehaviorId<number>> would be number
* ToBehaviorIdValueType<EventId<string>> would be never
* ToBehaviorIdValueType\<B\> is a utility type that equals T, if B extends BehaviorId\<T\>, else never.
*
* @typedef {T | never} T | never - the resulting type
* ```ts
* ToBehaviorIdValueType<BehaviorId<number>> = number
* ToBehaviorIdValueType<EventId<string>> = never
* ```
*
* @template B - the generic argument to ToBehaviorIdValueType
* @template T - the inferred generic parameter of B, if B extends BehaviorId<T>
* @template T - the inferred generic parameter of B, if B extends BehaviorId\<T\>
*/
export declare type ToBehaviorIdValueType<B> = B extends BehaviorId<infer T> ? T : never;
/**
* ToEventIdValueType<E> is a utility type that equals T, if E extends EventId<T>, else never.
* Examples:
* ToEventIdValueType<EventId<number>> would be number
* ToEventIdValueType<BehaviorId<string>> would be never
* ToEventIdValueType\<E\> is a utility type that equals T, if E extends EventId\<T\>, else never.
*
* @typedef {T | never} T | never - the resulting type
* ```ts
* ToEventIdValueType<EventId<number>> = number
* ToEventIdValueType<BehaviorId<string>> = never
* ```
*
* @template E - the generic argument to ToEventIdValueType
* @template T - the inferred generic parameter of E, if E extends EventId<T>
* @template T - the inferred generic parameter of E, if E extends EventId\<T\>
*/
export declare type ToEventIdValueType<E> = E extends EventId<infer T> ? T : never;
/**
* ToSignalIdValueType<S> is a utility type that equals T, if S extends SignalId<T>, else never.
* Examples:
* ToSignalIdValueType<EventId<number>> would be number
* ToSignalIdValueType<EventId<string>> would be string
* ToSignalIdValueType<number> would be never
* ToSignalIdValueType\<S\> is a utility type that equals T, if S extends SignalId\<T\>, else never.
*
* @typedef {T | never} T | never - the resulting type
* ```ts
* ToSignalIdValueType<EventId<number>> = number
* ToSignalIdValueType<EventId<string>> = string
* ToSignalIdValueType<number> = never
* ```
*
* @template S - the generic argument to ToSignalIdValueType
* @template T - the inferred generic parameter of S, if S extends SignalId<T>
* @template T - the inferred generic parameter of S, if S extends SignalId\<T\>
*/
export declare type ToSignalIdValueType<S> = S extends SignalId<infer T> ? T : never;
/**
* ToObservableValueType<O> is a utility type that equals T, if O extends Observable<T>, else never.
* Examples:
* ToObservableValueType<Observable<number>> would be number
* ToObservableValueType<Observable<string>> would be string
* ToObservableValueType<number> would be never
* ToObservableValueType\<O\> is a utility type that equals T, if O extends Observable\<T\>, else never.
*
* @typedef {T | never} T | never - the resulting type
* ```ts
* ToObservableValueType<Observable<number>> = number
* ToObservableValueType<Observable<string>> = string
* ToObservableValueType<number> = never
* ```
*
* @template O - the generic argument to ToObservableValueType
* @template T - the inferred generic parameter of O, if O extends Observable<T>
* @template T - the inferred generic parameter of O, if O extends Observable\<T\>
*/

@@ -121,10 +118,8 @@ export declare type ToObservableValueType<O> = O extends Observable<infer T> ? T : never;

* The rx-signals Store uses this type to uniquely identify all of its result effects.
* An EffectId<InputType, ResultType> does not make any use of the generic parameters itself,
* An EffectId\<InputType, ResultType\> does not make any use of the generic parameters itself,
* but is given these parameters only as a trick to let Typescript infer and thus enforce the correct types.
* Use the getEffectId<InputType, ResultType>() function to generate a corresponding ID.
* Use the {@link getEffectId} function to generate a corresponding ID.
*
* @typedef {object} EffectId<InputType, ResultType> - type to uniquely identify a certain result effect
* @template InputType - specifies the type for the corresponding effects input
* @template ResultType - specifies the type for the corresponding effects result
* @property {symbol} symbol - a symbol, making the EffectId unique
*/

@@ -138,4 +133,4 @@ export declare type EffectId<InputType, ResultType> = symbol & {

*
* @template T - specifies the type for the corresponding behavior
* @param {string} nameExtension - an optional extension to the symbol name (so the string representation). Usually, you don't need this, cause even for debugging purposes, you should use store.setIdName/getIdName.
* @template T - specifies the value-type for the corresponding behavior
* @param {string} nameExtension - an optional extension to the symbol name (so the string representation). Usually, you don't need this, cause even for debugging purposes, you should use {@link Store.setIdName} and {@link Store.getIdName}.
* @returns {StateId<T>}

@@ -147,4 +142,4 @@ */

*
* @template T - specifies the type for the corresponding behavior
* @param {string} nameExtension - an optional extension to the symbol name (so the string representation). Usually, you don't need this, cause even for debugging purposes, you should use store.setIdName/getIdName.
* @template T - specifies the value-type for the corresponding behavior
* @param {string} nameExtension - an optional extension to the symbol name (so the string representation). Usually, you don't need this, cause even for debugging purposes, you should use {@link Store.setIdName} and {@link Store.getIdName}.
* @returns {DerivedId<T>}

@@ -156,4 +151,4 @@ */

*
* @template T - specifies the type for the corresponding event
* @param {string} nameExtension - an optional extension to the symbol name (so the string representation). Usually, you don't need this, cause even for debugging purposes, you should use store.setIdName/getIdName.
* @template T - specifies the value-type for the corresponding event
* @param {string} nameExtension - an optional extension to the symbol name (so the string representation). Usually, you don't need this, cause even for debugging purposes, you should use {@link Store.setIdName} and {@link Store.getIdName}.
* @returns {EventId<T>}

@@ -160,0 +155,0 @@ */

@@ -8,4 +8,4 @@ let stateExtension = 1;

*
* @template T - specifies the type for the corresponding behavior
* @param {string} nameExtension - an optional extension to the symbol name (so the string representation). Usually, you don't need this, cause even for debugging purposes, you should use store.setIdName/getIdName.
* @template T - specifies the value-type for the corresponding behavior
* @param {string} nameExtension - an optional extension to the symbol name (so the string representation). Usually, you don't need this, cause even for debugging purposes, you should use {@link Store.setIdName} and {@link Store.getIdName}.
* @returns {StateId<T>}

@@ -17,4 +17,4 @@ */

*
* @template T - specifies the type for the corresponding behavior
* @param {string} nameExtension - an optional extension to the symbol name (so the string representation). Usually, you don't need this, cause even for debugging purposes, you should use store.setIdName/getIdName.
* @template T - specifies the value-type for the corresponding behavior
* @param {string} nameExtension - an optional extension to the symbol name (so the string representation). Usually, you don't need this, cause even for debugging purposes, you should use {@link Store.setIdName} and {@link Store.getIdName}.
* @returns {DerivedId<T>}

@@ -26,4 +26,4 @@ */

*
* @template T - specifies the type for the corresponding event
* @param {string} nameExtension - an optional extension to the symbol name (so the string representation). Usually, you don't need this, cause even for debugging purposes, you should use store.setIdName/getIdName.
* @template T - specifies the value-type for the corresponding event
* @param {string} nameExtension - an optional extension to the symbol name (so the string representation). Usually, you don't need this, cause even for debugging purposes, you should use {@link Store.setIdName} and {@link Store.getIdName}.
* @returns {EventId<T>}

@@ -30,0 +30,0 @@ */

import { Observable } from 'rxjs';
import { BehaviorId, DerivedId, EffectId, EventId, SignalId, StateId, ToBehaviorIdValueType, ToEventIdValueType, ToSignalIdValueType } from './store-utils';
/**
* The rx-signals Store uses the TypedEvent<T> to bundle certain events and their
* corresponding EventId<T>. This is used for EventSources that can dispatch events
* The {@link Store} uses the TypedEvent\<T\> to bundle certain events and their
* corresponding EventId\<T\>. This is used for EventSources that can dispatch events
* of different types (see addXTypedEventSource methods) or for cases where you want to
* subscribe multiple events and need to differentiate between them at runtime.
*
* @typedef {object} TypedEvent<T> - type for an object bundling identifier and corresponding event.
* @template T - specifies the type for the corresponding EventId<T>
* @property {EventId<T>} type - the EventId for the event
* @property {T} event - the event itself
* @template T - specifies the type for the corresponding event-values
*/

@@ -19,11 +16,7 @@ export declare type TypedEvent<T> = Readonly<{

/**
* The state reducer type specifies the signature for reducers used by the store.
* The state reducer type specifies the signature for reducers used by the {@link Store}.
* StateReducers must be pure functions.
*
* @typedef {function} StateReducer<T, E> - type for a pure function that takes a state and an event and returns a new state
* @template T - representing the type of the state
* @template E - representing the type of the event
* @property {T} state - the current state
* @property {E} event - the event
* @returns {T} - the new state
*/

@@ -33,16 +26,15 @@ export declare type StateReducer<T, E> = (state: T, event: E) => T;

* A LifecycleHandle can be used to control signals and signal-sources that
* are added to the store by store.getLifecycleHandle
*
* @property {function} reset - reset all behaviors corresponding to this lifecycle
* @property {function} end - remove all sources of this lifecycle and complete all corresponding behaviors (event-subscribers will NOT get a complete!)
* are added to the {@link Store} by store.getLifecycleHandle
*/
export declare type LifecycleHandle = {
/** reset all behaviors corresponding to this lifecycle */
reset: () => void;
/** reset all behaviors corresponding to this lifecycle */
end: () => void;
};
/**
* The Effect type specifies a potentially impure function that takes an input and the store as arguments
* The Effect type specifies a potentially impure function that takes an input and a {@link Store} as arguments
* and returns an effectful result as Observable.
* It is the low-level abstraction used by rx-signals for side-effect isolation.
* The high-level abstraction EffectSignalsFactory takes an EffectId as configuration to access
* The high-level abstraction {@link EffectSignalsFactory} takes an EffectId as configuration to access
* the corresponding Effect.

@@ -54,14 +46,17 @@ * The store argument can be used to access additional input from the store (thus, the Effect itself could also

*
* @typedef {function} Effect<Input, Result> - function performing an effect and returning an observable with the result
* @template Input - specifies the input type for the effect
* @template Result - specifies the result type for the effect
* @property {Input} input - the effect input
* @property {Store} store - the Store instance that will be passed to the function (e.g. to inject some other Effect).
* @property {Input | undefined} previousInput - the input of the previous function invocation, or undefined
* @property {Result | undefined} previousResult - the result of the previous function invocation, or undefined
*/
export declare type Effect<Input, Result> = (input: Input, store: Store, previousInput?: Input, previousResult?: Result) => Observable<Result>;
export declare type Effect<Input, Result> = (
/** the effect input */
input: Input,
/** the Store instance that will be passed to the function (e.g. to inject some other Effect) */
store: Store,
/** the input of the previous function invocation, or undefined */
previousInput?: Input,
/** the result of the previous function invocation, or undefined */
previousResult?: Result) => Observable<Result>;
/**
* The rx-signals Store provides RxJs-Observables for RP (reactive programming) BehaviorStreams
* and EventStreams (behaviors and events are the two different types of signals, where behaviors represent state).
* The rx-signals Store provides RxJs-Observables for RP (reactive programming) - BehaviorStreams
* and EventStreams (behaviors and events are the two different types of signals, where behaviors represent immutable state).
* The Store separates the sources of these streams from the streams itself.

@@ -212,3 +207,3 @@ *

* This method takes a callback that performs Store operations.
* It returns a LifecycleHandle that can be used to reset or end the lifecycle of signals
* It returns a {@link LifecycleHandle} that can be used to reset or end the lifecycle of signals
* and signal-sources that are added to the store during the callback execution.

@@ -241,4 +236,2 @@ *

* Technically, this is done by first removing all sources and then adding them again.
*
* @returns {void} - the behavior observable (shared and distinct)
*/

@@ -262,3 +255,3 @@ resetBehaviors(): void;

/**
* This method adds an event source to the Store. There can be multiple sources
* This method adds an event source to the store. There can be multiple sources
* for the same event type. However, each source must be identified by its own

@@ -326,3 +319,3 @@ * symbol and adding two sources with the same symbol would result in an error.

*/
add5TypedEventSource<A, B, C, D, E>(eventIdentifierA: EventId<A>, eventIdentifierB: EventId<B>, eventIdentifierC: EventId<C>, eventIdentifierD: EventId<D>, eventIdentifierE: EventId<E>, observable: Observable<TypedEvent<A> | TypedEvent<B> | TypedEvent<C> | TypedEvent<D> | TypedEvent<E>>, subscribeObservableOnlyIfEventIsSubscribed?: EventId<any> | null): symbol;
add5TypedEventSource<IDA extends EventId<any>, IDB extends EventId<any>, IDC extends EventId<any>, IDD extends EventId<any>, IDE extends EventId<any>>(eventIdentifierA: IDA, eventIdentifierB: IDB, eventIdentifierC: IDC, eventIdentifierD: IDD, eventIdentifierE: IDE, observable: Observable<TypedEvent<ToEventIdValueType<IDA>> | TypedEvent<ToEventIdValueType<IDB>> | TypedEvent<ToEventIdValueType<IDC>> | TypedEvent<ToEventIdValueType<IDD>> | TypedEvent<ToEventIdValueType<IDE>>>, subscribeObservableOnlyIfEventIsSubscribed?: EventId<any> | null): symbol;
/**

@@ -341,3 +334,3 @@ * See add2TypedEventSource

*/
add6TypedEventSource<A, B, C, D, E, F>(eventIdentifierA: EventId<A>, eventIdentifierB: EventId<B>, eventIdentifierC: EventId<C>, eventIdentifierD: EventId<D>, eventIdentifierE: EventId<E>, eventIdentifierF: EventId<F>, observable: Observable<TypedEvent<A> | TypedEvent<B> | TypedEvent<C> | TypedEvent<D> | TypedEvent<E> | TypedEvent<F>>, subscribeObservableOnlyIfEventIsSubscribed?: EventId<any> | null): symbol;
add6TypedEventSource<IDA extends EventId<any>, IDB extends EventId<any>, IDC extends EventId<any>, IDD extends EventId<any>, IDE extends EventId<any>, IDF extends EventId<any>>(eventIdentifierA: IDA, eventIdentifierB: IDB, eventIdentifierC: IDC, eventIdentifierD: IDD, eventIdentifierE: IDE, eventIdentifierF: IDF, observable: Observable<TypedEvent<ToEventIdValueType<IDA>> | TypedEvent<ToEventIdValueType<IDB>> | TypedEvent<ToEventIdValueType<IDC>> | TypedEvent<ToEventIdValueType<IDD>> | TypedEvent<ToEventIdValueType<IDE>> | TypedEvent<ToEventIdValueType<IDF>>>, subscribeObservableOnlyIfEventIsSubscribed?: EventId<any> | null): symbol;
/**

@@ -354,3 +347,3 @@ * This method removes the specified event source.

* and share(). So events will always be received asynchronously (expecting synchronous event dispatch would
* be a strong indicator of flawed design, because it could break MVU/reactivity).
* be a strong indicator of flawed design, because it could break reactivity).
* If this store has a parent store, events from both, parent and child will be observed (merged).

@@ -357,0 +350,0 @@ *

@@ -1,3 +0,2 @@

import { asyncScheduler, BehaviorSubject, merge, NEVER, of } from 'rxjs';
import { delay, distinctUntilChanged, filter, map, share, switchMap, take, withLatestFrom, } from 'rxjs/operators';
import { asyncScheduler, BehaviorSubject, delay, distinctUntilChanged, filter, firstValueFrom, map, merge, NEVER, of, share, switchMap, take, withLatestFrom, } from 'rxjs';
import { ControlledSubject } from './controlled-subject';

@@ -8,4 +7,4 @@ import { DelayedEventQueue } from './delayed-event-queue';

/**
* The rx-signals Store provides RxJs-Observables for RP (reactive programming) BehaviorStreams
* and EventStreams (behaviors and events are the two different types of signals, where behaviors represent state).
* The rx-signals Store provides RxJs-Observables for RP (reactive programming) - BehaviorStreams
* and EventStreams (behaviors and events are the two different types of signals, where behaviors represent immutable state).
* The Store separates the sources of these streams from the streams itself.

@@ -242,3 +241,3 @@ *

* This method takes a callback that performs Store operations.
* It returns a LifecycleHandle that can be used to reset or end the lifecycle of signals
* It returns a {@link LifecycleHandle} that can be used to reset or end the lifecycle of signals
* and signal-sources that are added to the store during the callback execution.

@@ -324,4 +323,2 @@ *

* Technically, this is done by first removing all sources and then adding them again.
*
* @returns {void} - the behavior observable (shared and distinct)
*/

@@ -336,5 +333,3 @@ resetBehaviors() {

if (controlledSubject.isObservableSubscribed()) {
const result = this.getEventStream(identifier)
.pipe(filter(val => val === event), take(1), map(() => true), delay(1, asyncScheduler))
.toPromise();
const result = firstValueFrom(this.getEventStream(identifier).pipe(filter(val => val === event), take(1), map(() => true), delay(1, asyncScheduler)));
controlledSubject.next(event);

@@ -346,3 +341,3 @@ return result;

/**
* This method adds an event source to the Store. There can be multiple sources
* This method adds an event source to the store. There can be multiple sources
* for the same event type. However, each source must be identified by its own

@@ -500,3 +495,3 @@ * symbol and adding two sources with the same symbol would result in an error.

* and share(). So events will always be received asynchronously (expecting synchronous event dispatch would
* be a strong indicator of flawed design, because it could break MVU/reactivity).
* be a strong indicator of flawed design, because it could break reactivity).
* If this store has a parent store, events from both, parent and child will be observed (merged).

@@ -503,0 +498,0 @@ *

import { Observable } from 'rxjs';
/**
* This function is a testing utility.
* It takes an observable and the expected number of values to be observed.
* The returned Promise either resolves to an array with the observed values, or rejects on error.
* If the expected number of values is not observed within the configurable timeout, the Promise resolves
* with the values observed so far.
*
* @template T - type for the values to be observed
* @param {Observable} observable - the observable.
* @param {number} length - the expected number of values to be observed before resolving the result-Promise.
* @param {number} timeoutAfter - the timeout for waiting on the expected number of values. Defaults to 3000ms
* @returns {Promise}
*/
export declare const getSequence: <T>(observable: Observable<T>, length: number, timeoutAfter?: number) => Promise<T[]>;
/**
* This function is a testing utility.
* It takes an observable and array of values.
* The returned Promise resolves as soon as the number of observed values equals the array-length AND the observed values equal the array-values (using expect with .toEqual).
* It rejects in all other cases, e.g. if the expected number of values was not observed within the configurable timeout.
*
* @template T - type for the values to be observed
* @param {Observable} observable - the observable.
* @param {number} sequence - the expected values.
* @param {number} timeoutAfter - the timeout for waiting on the expected values. Defaults to 3000ms
* @returns {Promise}
*/
export declare const expectSequence: <T>(observable: Observable<T>, sequence: T[], timeoutAfter?: number) => Promise<void>;
export declare const awaitStringifyEqualState: <T>(observable: Observable<T>, expectedState: T, timeoutAfter?: number) => Promise<void>;
export declare const awaitError: (observable: Observable<any>, timeoutAfter?: number) => Promise<void>;
export declare const awaitCompletion: (observable: Observable<any>) => Promise<void>;
export declare const withSubscription: (observable: Observable<any>, callback: () => Promise<void>) => Promise<void>;

@@ -10,4 +10,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

};
import { combineLatest, of } from 'rxjs';
import { combineLatest, firstValueFrom, of } from 'rxjs';
import { catchError, delay, filter, map, scan, startWith, take, timeout } from 'rxjs/operators';
/**
* This function is a testing utility.
* It takes an observable and the expected number of values to be observed.
* The returned Promise either resolves to an array with the observed values, or rejects on error.
* If the expected number of values is not observed within the configurable timeout, the Promise resolves
* with the values observed so far.
*
* @template T - type for the values to be observed
* @param {Observable} observable - the observable.
* @param {number} length - the expected number of values to be observed before resolving the result-Promise.
* @param {number} timeoutAfter - the timeout for waiting on the expected number of values. Defaults to 3000ms
* @returns {Promise}
*/
export const getSequence = (observable, length, timeoutAfter = 3000) => __awaiter(void 0, void 0, void 0, function* () {

@@ -17,7 +30,16 @@ const accObservable = observable.pipe(scan((acc, next) => [...acc, next], []), startWith([]));

const combined = combineLatest([accObservable, timeoutObservable]);
return combined
.pipe(filter(([result, hasTimedOut]) => hasTimedOut || result.length === length), map(([result]) => result), take(1))
.toPromise(); // Deprecated and will be removed in rxjs8
// However, we must still support rxjs 6.x as peer dependency
return firstValueFrom(combined.pipe(filter(([result, hasTimedOut]) => hasTimedOut || result.length === length), map(([result]) => result), take(1)));
});
/**
* This function is a testing utility.
* It takes an observable and array of values.
* The returned Promise resolves as soon as the number of observed values equals the array-length AND the observed values equal the array-values (using expect with .toEqual).
* It rejects in all other cases, e.g. if the expected number of values was not observed within the configurable timeout.
*
* @template T - type for the values to be observed
* @param {Observable} observable - the observable.
* @param {number} sequence - the expected values.
* @param {number} timeoutAfter - the timeout for waiting on the expected values. Defaults to 3000ms
* @returns {Promise}
*/
export const expectSequence = (observable, sequence, timeoutAfter = 3000) => __awaiter(void 0, void 0, void 0, function* () {

@@ -28,2 +50,5 @@ return getSequence(observable, sequence.length, timeoutAfter).then(result => {

});
/**
* @internal
*/
export const awaitStringifyEqualState = (observable, expectedState, timeoutAfter = 3000) => __awaiter(void 0, void 0, void 0, function* () {

@@ -38,2 +63,5 @@ return new Promise(resolve => {

});
/**
* @internal
*/
export const awaitError = (observable, timeoutAfter = 3000) => __awaiter(void 0, void 0, void 0, function* () {

@@ -48,7 +76,13 @@ return new Promise(resolve => {

});
/**
* @internal
*/
export const awaitCompletion = (observable) => __awaiter(void 0, void 0, void 0, function* () {
return new Promise((resolve, reject) => {
observable.subscribe(() => { }, reject, resolve);
observable.subscribe({ next: () => { }, error: reject, complete: resolve });
});
});
/**
* @internal
*/
export const withSubscription = (observable, callback) => __awaiter(void 0, void 0, void 0, function* () {

@@ -55,0 +89,0 @@ const subscription = observable.subscribe();

@@ -1,31 +0,8 @@

declare type ConflictKeys<T1 extends Record<string, any>, T2 extends Record<string, any>> = {
[K in keyof T1]: K extends keyof T2 ? K : never;
}[keyof T1];
declare type NoConflictKeys<T1 extends Record<string, any>, T2 extends Record<string, any>> = {
[K in keyof T1]: K extends keyof T2 ? never : K;
}[keyof T1];
declare type Conflicts<T1 extends Record<string, any>, T2 extends Record<string, any>> = {
[K in ConflictKeys<T1, T2>]: T1[K];
};
declare type NoConflicts<T1 extends Record<string, any>, T2 extends Record<string, any>> = {
[K in NoConflictKeys<Omit<T1, 'conflicts1' | 'conflicts2'>, T2>]: T1[K];
};
declare type MergeResult<T1 extends Record<string, any>, T2 extends Record<string, any>> = ConflictKeys<T1, T2> extends never ? T1 & T2 : NoConflicts<T1, T2> & NoConflicts<T2, T1> & {
conflicts1: Conflicts<T1, T2> & ('conflicts1' extends keyof T1 ? {
conflicts1: T1['conflicts1'];
} : {}) & ('conflicts2' extends keyof T1 ? {
conflicts2: T1['conflicts2'];
} : {});
conflicts2: Conflicts<T2, T1> & ('conflicts1' extends keyof T2 ? {
conflicts1: T2['conflicts1'];
} : {}) & ('conflicts2' extends keyof T2 ? {
conflicts2: T2['conflicts2'];
} : {});
};
/**
* This type represents the result of a merge of two Record<string, any> types T1 and T2, using the following rules:
* a) If there are no conflicts between T1 and T2, then Merged<T1, T2> equals T1 & T2
* b) If there's a conflict between T1 and T2, then Merged<T1, T2> equals { conflicts1: ConflictsFromT1; conflicts2: ConflictsFromT2 } & NoConflicts<T1, T2>
* This type represents the result of a merge of two Record\<string, any\> types T1 and T2, using the following rules:
* a) If there are no conflicts between T1 and T2, then Merged\<T1, T2\> equals T1 & T2
* b) If there's a conflict between T1 and T2, then Merged\<T1, T2\> equals \{ conflicts1: ConflictsFromT1; conflicts2: ConflictsFromT2 \} & NoConflicts\<T1, T2\>
*
* Here are some examples:
* ```ts
* Merged<{

@@ -56,4 +33,5 @@ * a: string;

* }
* ```
*
*
* ```ts
* Merged<{

@@ -85,28 +63,23 @@ * conflicts1: {

* }
*
* @typedef {object} Merged<T1 extends Record<string, any>, T2 extends Record<string, any>> - result of merge for T1 and T2
* ```
*/
export declare type Merged<T1 extends Record<string, any>, T2 extends Record<string, any>> = MergeResult<T1, T2>;
/**
* This function merges two Record<string, any> T1 and T2, resulting in Merged<T1, T2>
* This function merges two Record\<string, any\> T1 and T2, resulting in Merged\<T1, T2\>
*
* @typedef {function} merge
* @template T1 - type for the first argument
* @template T2 - type for the second argument
* @param {T1} t1 - first argument (extending Record<string, any>).
* @param {T2} t2 - second argument (extending Record<string, any>).
* @returns {Merged<T1, T2>}
* @param {T1} t1 - first argument (extending Record\<string, any\>).
* @param {T2} t2 - second argument (extending Record\<string, any\>).
* @returns {Merged}
*/
export declare const merge: <T1 extends Record<string, any>, T2 extends Record<string, any>>(t1: T1, t2: T2) => MergeResult<T1, T2>;
/**
* Just a type alias for Record<string, any>
* Just a type alias for Record\<string, any\>
*/
export declare type Configuration = Record<string, any>;
declare type NM<T1 extends Configuration, T2 extends Configuration> = T1 & T2;
/**
* This type represents the result of a merge of two Configuration types T1 and T2, using the following rules:
* a) If either T1 or T2 is an empty object, then MergedConfiguration<T1, T2> equals T1 & T2
* b) If both, T1 and T2, are non-empty then MergedConfiguration<T1, T2> equals { c1: T1; c2: T2 }
*
* @typedef {object} MergedConfiguration<T1 extends Configuration, T2 extends Configuration> - result of merge for T1 and T2
* a) If either T1 or T2 is an empty object, then MergedConfiguration\<T1, T2\> equals T1 & T2
* b) If both, T1 and T2, are non-empty then MergedConfiguration\<T1, T2\> equals \{ c1: T1; c2: T2 \}
*/

@@ -129,2 +102,1 @@ export declare type MergedConfiguration<T1 extends Configuration, T2 extends Configuration> = keyof T1 extends never ? NM<T1, T2> : keyof T2 extends never ? NM<T1, T2> : {

};
export {};
/**
* This function merges two Record<string, any> T1 and T2, resulting in Merged<T1, T2>
* This function merges two Record\<string, any\> T1 and T2, resulting in Merged\<T1, T2\>
*
* @typedef {function} merge
* @template T1 - type for the first argument
* @template T2 - type for the second argument
* @param {T1} t1 - first argument (extending Record<string, any>).
* @param {T2} t2 - second argument (extending Record<string, any>).
* @returns {Merged<T1, T2>}
* @param {T1} t1 - first argument (extending Record\<string, any\>).
* @param {T2} t2 - second argument (extending Record\<string, any\>).
* @returns {Merged}
*/

@@ -11,0 +10,0 @@ export const merge = (t1, t2) => {

@@ -5,28 +5,28 @@ import { EffectError, EffectSuccess } from './effect-signals-factory';

/**
* This specifies the type for the lazy combined-behavior provided as output-signal of the ValidatedInputWithResultFactory.
* This specifies the type for the lazy combined-behavior provided as output-signal of the {@link ValidatedInputWithResultFactory}.
*
* @typedef {object} ValidatedInputWithResult<Input, ValidationResult, Result> - type for the behavior produced by ValidatedInputWithResultFactory
* @template Input - specifies the input type for both, the validation-effect and the result-effect
* @template ValidationResult - specifies the result-type of the validation-effect
* @template Result - specifies the result-type of the result-effect
* @property {Input | undefined} currentInput - current input (which might differ from the resultInput)
* @property {Input | undefined} validatedInput - the input that produced the current validationResult (or undefined, if validationResult is undefined)
* @property {ValidationResult | undefined} validationResult - the current validationResult (or undefined, if no validation-result was received yet)
* @property {boolean} validationPending - indicates whether the validation-effect is currently running.
* @property {Input | undefined} resultInput - the input that produced the current result (or undefined, if result is undefined)
* @property {Result | undefined} result - the current result (or undefined, if no result was received yet)
* @property {boolean} resultPending - indicates whether the result-effect is currently running.
*/
export declare type ValidatedInputWithResult<Input, ValidationResult, Result> = {
/** current input (which might differ from the resultInput) */
currentInput?: Input;
/** indicates whether the validation-effect is currently running */
validationPending: boolean;
/** the input that produced the current validationResult (or undefined, if validationResult is undefined) */
validatedInput?: Input;
/** the current validationResult (or undefined, if no validation-result was received yet) */
validationResult?: ValidationResult;
/** whether the current validationResult represents a valid state (false, if current validationResult is undefined) */
isValid: boolean;
/** indicates whether the result-effect is currently running */
resultPending: boolean;
/** the input that produced the current result (or undefined, if result is undefined) */
resultInput?: Input;
/** the current result (or undefined, if no result was received yet) */
result?: Result;
};
/**
* The analog to EffectInputSignals, just for ValidatedInputWithResultFactory.
* The analog to {@link EffectInputSignals}, just for {@link ValidatedInputWithResultFactory}.
*/

@@ -40,3 +40,3 @@ export declare type ValidatedInputWithResultInput<Input> = {

/**
* The analog to EffectOutputSignals, just for ValidatedInputWithResultFactory.
* The analog to {@link EffectOutputSignals}, just for {@link ValidatedInputWithResultFactory}.
*/

@@ -51,3 +51,3 @@ export declare type ValidatedInputWithResultOutput<Input, ValidationResult, Result> = {

/**
* The analog to EffectConfiguration, just for ValidatedInputWithResultFactory.
* The analog to {@link EffectConfiguration}, just for {@link ValidatedInputWithResultFactory}.
*/

@@ -65,3 +65,3 @@ export declare type ValidatedInputWithResultConfig<Input, ValidationResult, Result> = {

/**
* The analog to EffectFactoryEffects, just for ValidatedInputWithResultFactory.
* The analog to {@link EffectFactoryEffects}, just for {@link ValidatedInputWithResultFactory}.
*/

@@ -73,3 +73,3 @@ export declare type ValidatedInputWithResultEffects<Input, ValidationResult, Result> = {

/**
* The ValidatedInputWithResultFactory is composed of two EffectSignalsFactory, to abstract over all
* The ValidatedInputWithResultFactory is composed of two {@link EffectSignalsFactory}s, to abstract over all
* scenarios where you need to validate a certain input and run a result-effect only if the validation

@@ -80,4 +80,4 @@ * has passed successfully.

/**
* Generic function to create a specific ValidatedInputWithResultFactory.
* Generic function to create a specific {@link ValidatedInputWithResultFactory}.
*/
export declare const getValidatedInputWithResultSignalsFactory: <Input, ValidationResult, Result>() => ValidatedInputWithResultFactory<Input, ValidationResult, Result>;

@@ -1,3 +0,2 @@

import { combineLatest } from 'rxjs';
import { distinctUntilChanged, filter, map, startWith } from 'rxjs/operators';
import { combineLatest, distinctUntilChanged, filter, map, startWith } from 'rxjs';
import { getEffectSignalsFactory, } from './effect-signals-factory';

@@ -39,3 +38,3 @@ import { getDerivedId } from './store-utils';

/**
* Generic function to create a specific ValidatedInputWithResultFactory.
* Generic function to create a specific {@link ValidatedInputWithResultFactory}.
*/

@@ -42,0 +41,0 @@ export const getValidatedInputWithResultSignalsFactory = () => getEffectSignalsFactory()

{
"name": "@rx-signals/store",
"version": "3.0.0-rc23",
"version": "3.0.0-rc24",
"description": "Reactive state- and effects-management with behaviors and event streams",

@@ -17,4 +17,4 @@ "author": "Gerd Neudert",

"build": "tsc -p tsconfig.json && tsc -p tsconfig-cjs.json",
"test": "jest --config jestconfig.json",
"test-coverage": "jest --config jestconfig.json --coverage",
"test": "jest --detectOpenHandles --config jestconfig.json",
"test-coverage": "jest --detectOpenHandles --config jestconfig.json --coverage",
"lint": "eslint --ext .ts \"src/**\"",

@@ -47,11 +47,11 @@ "generate-docs": "typedoc --out docs/tsdoc src",

],
"peerDependencies": {
"rxjs": ">6.4.0"
"dependencies": {
"rxjs": "^7.5.5"
},
"devDependencies": {
"@types/jest": "^27.4.1",
"@types/jest": "^28.1.8",
"@typescript-eslint/eslint-plugin": "^5.16.0",
"@typescript-eslint/parser": "^5.16.0",
"eslint": "^8.11.0",
"eslint-config-airbnb-typescript": "^16.1.4",
"eslint-config-airbnb-typescript": "^17.0.0",
"eslint-config-prettier": "^8.5.0",

@@ -62,9 +62,8 @@ "eslint-plugin-import": "^2.25.4",

"eslint-plugin-prettier": "^4.0.0",
"jest": "^27.5.1",
"jest": "^28.1.3",
"prettier": "^2.6.0",
"rxjs": "^7.5.5",
"ts-jest": "^27.1.3",
"typedoc": "^0.22.13",
"ts-jest": "^28.0.8",
"typedoc": "^0.23.10",
"typescript": "^4.6.2"
}
}

@@ -6,5 +6,6 @@ # _@rx-signals/store_

:warning: This documentation is work in progress for the upcoming 3.0.0 version.
There is however no good reason to use 2.x over 3.0.0-rc23, so please start with the rc-version (3.0.0 will be the first version I'm going to advertise publicly, so it's more like a 1.0 in reality.).
There is however no good reason to use 2.x over 3.0.0-rc24, so please start with the rc-version (3.0.0 will be the first version I'm going to advertise publicly, so it's more like a 1.0 in reality.).
2.x is deprecated and will NOT be maintained in any way.
3.0.0-rc23 is better than 2.x in any aspect and the code is production-ready.
3.0.0-rc24 is better than 2.x in any aspect and the code is production-ready.
It's mainly documentation that needs improvement for a final realease (though 2.x had no documentation at all, apart from doc-strings).

@@ -15,7 +16,7 @@ It is however possible that I will introduce minor breaking changes until 3.0.0 is finally released.

**`npm install --save @rx-signals/store@3.0.0-rc23`**
**`npm install --save @rx-signals/store@3.0.0-rc24`**
## Dependencies
**_RxJs_** is the one and only peer dependency. You need a version >6.4.0 (so 7.x is also perfectly fine) in your project.
**_RxJs_** is the one and only dependency.

@@ -31,3 +32,3 @@ ## License

It is however not limited to MVU, but can be used in all architectures that would benefit from its features:
* State Management
* Immutable State Management
* Global and/or local

@@ -60,2 +61,3 @@ * Reactive Programming

* SignalsFactory that covers side-effect-scenarios generically, encapsulating and abstracting away all the pitfalls and possibilities to shoot yourself in the foot.
* Full type-safety everywhere

@@ -69,3 +71,3 @@ See [**_rx-signals_ design goals**](https://github.com/gneu77/rx-signals/blob/master/docs/rx-signals_start.md#design) for more.

What does _rx-signals_ mean anyway?
Well the _rx_ stands for reactive extensions, so it's the same _rx_ as in _RxJs_.
Well the _rx_ stands for reactive extensions, so it's the same _rx_ as in _RxJs_, giving tribute to this congenial lib that is the base of _rx-signals_.
The term _signals_ is lent from the world of functional reactive programming (FRP), that knows two types of signals.

@@ -75,3 +77,3 @@ The first type are _Events_ being a signal of values occurring at discrete points of time.

In RP (Reactive Programming), we can defined _Events_ and _Behaviors_ as follows:<a name="rp-signals-definition"></a>
In RP (Reactive Programming), we can define _Events_ and _Behaviors_ as follows:<a name="rp-signals-definition"></a>
* Event-streams:

@@ -78,0 +80,0 @@ * Value-streams that have no current value

@@ -0,1 +1,4 @@

/**
* @internal
*/
export class ContextHandle {

@@ -2,0 +5,0 @@ private active = false;

/* eslint no-underscore-dangle: ["error", { "allow": ["_rxs_id"] }] */
import { BehaviorSubject, Observable, Subject, Subscription } from 'rxjs';
import { distinctUntilChanged, filter, share } from 'rxjs/operators';
import {
BehaviorSubject,
distinctUntilChanged,
filter,
Observable,
share,
Subject,
Subscription,
} from 'rxjs';
import { ContextHandle } from './context-handle';

@@ -9,7 +16,17 @@ import { DelayedEventQueue } from './delayed-event-queue';

export interface ResetHandle {
/**
* Used by the {@link Store}
*
* @internal
*/
export type ResetHandle = {
removeSources(): void;
readdSources(): void;
}
};
/**
* Used by the {@link Store}
*
* @internal
*/
export class ControlledSubject<T> {

@@ -16,0 +33,0 @@ private subject!: Subject<T> | BehaviorSubject<T>;

@@ -1,4 +0,8 @@

import { Observable, Subject } from 'rxjs';
import { map, mergeMap } from 'rxjs/operators';
import { map, mergeMap, Observable, Subject } from 'rxjs';
/**
* Used by the {@link Store}
*
* @internal
*/
export class DelayedEventQueue {

@@ -5,0 +9,0 @@ private queueArray: Subject<void>[] = [];

@@ -1,3 +0,12 @@

import { combineLatest, of, throwError } from 'rxjs';
import { catchError, debounceTime, filter, map, switchMap, take } from 'rxjs/operators';
import {
catchError,
combineLatest,
debounceTime,
filter,
map,
of,
switchMap,
take,
throwError,
} from 'rxjs';
import { Signals, SignalsFactory } from './signals-factory';

@@ -17,16 +26,18 @@ import { Effect, Store } from './store';

/**
* This specifies the type for the lazy behavior produced by EffectSignals.
* Value-type for the derived behavior produced by {@link EffectSignals}.
*
* @typedef {object} CombinedEffectResult<Input, Result> - type for the behavior produced by effect signal factories
* @template Input - specifies the input type for the effect
* @template Result - specifies the result type of the effect
* @property {Input | undefined} currentInput - current input (which might differ from the resultInput)
* @property {Input | undefined} resultInput - the input that produced the current result (or undefined, if result is undefined)
* @property {Result | undefined} result - the current result (or undefined, if no result was received yet)
* @property {boolean} resultPending - indicates whether the effect is currently running. (In case of a factory without trigger, this will be true whenever currentInput !== resultInput, or whenever an invalidation event has been sent)
*/
export type CombinedEffectResult<Input, Result> = {
/** current input (which might differ from the resultInput) */
currentInput?: Input;
/** the current result (or undefined, if no result was received yet) */
result?: Result;
/** the input that produced the current result (or undefined, if result is undefined) */
resultInput?: Input;
/** indicates whether the effect is currently running. (In case of a factory without trigger, this will be true whenever currentInput !== resultInput, or whenever an invalidation event has been sent) */
resultPending: boolean;

@@ -36,11 +47,11 @@ };

/**
* Type for error events produced by an EffectSignals (unhandled effect errors).
* Value-type for error events produced by an {@link EffectSignals} (unhandled effect errors).
*
* @typedef {object} EffectError<Input> - type for error events produced by EffectSignals
* @template Input - specifies the input type for the effect
* @property {any} error - the unhandled error thrown by an effect
* @property {Input} errorInput - the effect input that lead to the error
*/
export type EffectError<Input> = {
/** the unhandled error thrown by an effect */
error: any;
/** the effect input that lead to the error */
errorInput: Input;

@@ -50,16 +61,18 @@ };

/**
* Type for success events produced by EffectSignals.
* Value-type for success events produced by {@link EffectSignals}.
*
* @typedef {object} EffectSuccess<Input, Result> - type for success events produced by EffectSignals
* @template Input - specifies the input type for the effect
* @template Result - specifies the result type of the effect
* @property {Result} result - the effect result
* @property {Input} resultInput - the effect input that lead to the result
* @property {Input | undefined} previousInput - the input of the previous result, or undefined
* @property {Result | undefined} previousResult - the previous result, or undefined
*/
export type EffectSuccess<Input, Result> = {
/** the effect result */
result: Result;
/** the effect input that lead to the result */
resultInput: Input;
/** the input of the previous result, or undefined */
previousInput?: Input;
/** the previous result, or undefined */
previousResult?: Result;

@@ -69,16 +82,17 @@ };

/**
* Type specifying the input EffectSignals (the corresponding signal-sources are NOT added to the store
* Type specifying the input {@link EffectSignals} (the corresponding signal-sources are NOT added to the store
* by the EffectSignals-setup, but by whoever uses the signals, e.g. by extendSetup or fmap or just using dispatch).
* The EffectSignalsFactory gives you the guarantee, that invalidate-events are NOT missed, even while
* The {@link EffectSignalsFactory} gives you the guarantee, that invalidate-events are NOT missed, even while
* the combined-behavior is not subscribed.
*
* @typedef {object} EffectInputSignals<Input> - object holding the input signal identifiers for EffectSignals
* @template Input - specifies the input type for the effect
* @property {DerivedId<Input>} input - identifier for the behavior being consumed by EffectSignals as input
* @property {EventId<undefined>} invalidate - identifier for the invalidation event that can be dispatched to trigger re-evaluation of the current input under the given effect
* @property {EventId<undefined>} trigger - identifier for the trigger event that can be dispatched to trigger the given effect. This event has only meaning, if withTrigger is configured (see EffectConfiguration)
*/
export type EffectInputSignals<Input> = {
/** identifier for the behavior being consumed by EffectSignals as input (see {@link EffectConfiguration} on how to configure your factory to subscribe the corresponding behavior eagerly) */
input: DerivedId<Input>;
/** identifier for the invalidation event that can be dispatched to trigger re-evaluation of the current input under the given effect */
invalidate: EventId<undefined>;
/** identifier for the trigger event that can be dispatched to trigger the given effect. This event has only meaning, if withTrigger is configured (see EffectConfiguration) */
trigger: EventId<undefined>;

@@ -88,14 +102,16 @@ };

/**
* Type specifying the output EffectSignals (signals produced EffectSignals).
* Type specifying the output {@link EffectSignals} (signals produced EffectSignals).
* The {@link EffectSignalsFactory} takes care that subscribing error- or success-events keeps the effect itself lazy (hence only subscribing the combined behavior will subscribe the effect itself).
*
* @typedef {object} EffectOutputSignals<Input, Result> - object holding the output signal identifiers
* @template Input - specifies the input type for the effect
* @template Result - specifies the result type of the effect
* @property {DerivedId<CombinedEffectResult<Input, Result>>} combined - identifier for the produced combined effect result behavior
* @property {EventId<EffectError<Input>>} errors - identifier for the produced error events
* @property {EventId<EffectSuccess<Input, Result>>} successes - identifier for the produced success events
*/
export type EffectOutputSignals<Input, Result> = {
/** identifier for the produced combined effect result behavior */
combined: DerivedId<CombinedEffectResult<Input, Result>>;
/** identifier for the produced error events */
errors: EventId<EffectError<Input>>;
/** identifier for the produced success events */
successes: EventId<EffectSuccess<Input, Result>>;

@@ -105,11 +121,10 @@ };

/**
* Type specifying the effects-type of EffectSignals (the corresponding effects are NOT added to the store
* Type specifying the effect-type of {@link EffectSignals} (the corresponding effects are NOT added to the store
* by the EffectSignals-setup, but by whoever uses the signals, e.g. by useExistingEffect or via extended configuration plus extendSetup).
*
* @typedef {object} EffectFactoryEffects<Input> - object holding the effect identifiers for EffectSignals
* @template Input - specifies the input type for the effect
* @template Result - specifies the result type of the effect
* @property {EffectId<Input, Result>} id - the id for the specific Effect function to be used
*/
export type EffectFactoryEffects<Input, Result> = {
/** the id for the specific Effect function to be used */
id: EffectId<Input, Result>;

@@ -121,2 +136,3 @@ };

* They fulfill the following requirements:
* ```markdown
* 1.) The produced CombinedEffectResult<Input, Result> behavior must be lazy, hence, as long as it is not subscribed,

@@ -130,6 +146,6 @@ * no effect will be triggered.

* subscribe the result behavior.
* ```
*
* See the documentation for EffectConfiguration<Input, Result> for further configuration of EffectSignals<Input, Result>.
* See the documentation for {@link EffectConfiguration} for further configuration of EffectSignals.
*
* @typedef {object} EffectSignals<Input, Result>
* @template Input - specifies the input type for the effect

@@ -145,22 +161,27 @@ * @template Result - specifies the result type of the effect

/**
* This type specifies the type of the argument to EffectSignalsBuild, hence the configuration of EffectSignals.
* This type specifies the type of the argument to {@link EffectSignalsBuild}, hence the configuration of {@link EffectSignals}.
*
* @typedef {object} EffectConfiguration<Input, Result>
* @template Input - specifies the input type for the effect
* @template Result - specifies the result type of the effect
* @property {function | undefined} effectInputEquals - optional function used to determine whether a new input equals the previous one. Defaults to strict equals (a === b)
* @property {boolean | undefined} withTrigger - optional bool that defaults to false. If true, the effect will only be performed in case a trigger event is received (else, whenever the input changes).
* @property {function | undefined} initialResultGetter - optional function that defaults to undefined. If not undefined, it will be used to determine an initial result for the result behavior.
* @property {number | undefined} effectDebounceTime - optional number that defaults to undefined. If a number > 0 is specified, then it will be used as milliseconds to debounce new input to the effect (please DON't debounce the input signal yourself, because that would debounce before trigger and/or input equals).
* @property {function | undefined} wrapperEffectGetter - optional function to wrap the effect defined by effectId with a custom Effect
* @property {boolean | undefined} eagerInputSubscription - optional bool to specify whether the input behavior should be subscribed eagerly (defaults to false)
* @property {string | undefined} nameExtension - optional string to be used as argument to calls of getBehaviorId and getEventId
*/
export type EffectConfiguration<Input, Result> = {
/** Function used to determine whether a new input equals the previous one. Defaults to strict equals (a === b) */
effectInputEquals?: (a: Input, b: Input) => boolean;
/** Defaults to false. If true, the effect will only be performed in case a trigger event is received (else, whenever the input changes) */
withTrigger?: boolean;
/** If defined, this function will be used to determine an initial result for the result behavior */
initialResultGetter?: () => Result;
/** If defined and >0, then it will be used as milliseconds to debounce new input to the effect (please DON't debounce the input signal yourself, because that would debounce before trigger and/or input equals!) */
effectDebounceTime?: number;
/** Function to wrap the effect defined by effectId with a custom Effect */
wrappedEffectGetter?: (effect: Effect<Input, Result>) => Effect<Input, Result>;
/** Specifies whether the input behavior should be subscribed eagerly (defaults to false) */
eagerInputSubscription?: boolean;
/** Optional string to be used as argument to calls of getBehaviorId and getEventId */
nameExtension?: string;

@@ -170,5 +191,4 @@ };

/**
* Type specifying the SignalsBuild function for EffectSignals.
* Type specifying the {@link SignalsBuild} function for {@link EffectSignals}, hence a function taking an {@link EffectConfiguration} and producing EffectSignals.
*
* @typedef {function} EffectSignalsBuild - function taking an EffectConfiguration and producing EffectSignals
* @template Input - specifies the input type for the effect

@@ -250,3 +270,3 @@ * @template Result - specifies the result type of the effect

// It is important to setup the combined observable as behavior,
// because a simple shareReplay (even with refCount) would create a memory leak!!!
// because a simple shareReplay (even with refCount) could create a memory leak!!!
const combinedId = getDerivedId<

@@ -382,5 +402,4 @@ [

/**
* This type specifies a SignalsFactory wrapping EffectSignals.
* This type specifies a {@link SignalsFactory} wrapping {@link EffectSignals}.
*
* @typedef {object} EffectSignalsFactory<Input, Result>
* @template Input - specifies the input type for the effect

@@ -397,3 +416,3 @@ * @template Result - specifies the result type of the effect

/**
* This function creates an EffectSignalsFactory<Input, Result>.
* This function creates an {@link EffectSignalsFactory}.
*

@@ -400,0 +419,0 @@ * @template Input - specifies the input type for the effect

@@ -6,9 +6,4 @@ export * from './effect-signals-factory';

export * from './store-utils';
export {
Configuration,
KeysOfValueType,
Merged,
MergedConfiguration,
WithValueType,
} from './type-utils';
export { expectSequence, getSequence } from './test-utils/test-utils';
export * from './type-utils';
export * from './validated-input-with-result-signals-factory';

@@ -5,14 +5,15 @@ import { Signals, SignalsFactory } from './signals-factory';

/**
* Type specifying the input signal ids produced by a ModelSignalsFactory (the corresponding signal-sources
* Type specifying the input signal ids produced by a {@link ModelSignalsFactory} (the corresponding signal-sources
* are NOT added to the store by the signals-setup, but by whoever uses the signals, e.g. by extendSetup or fmap or just using dispatch).
*
* @typedef {object} ModelInputSignals<T> - object holding the input signal identifiers for ModelSignals
* @template T - the type of the model to be handled
* @property {EventId<T>} setModel - identifier for the event to replace the complete model
* @property {EventId<Partial<T>>} updateModel - identifier for the event to update the model by a given partial model
* @property {EventId<undefined>} resetModel - identifier for the event to reset the model to the configured default
*/
export type ModelInputSignals<T> = {
/** identifier for the event to replace the complete model */
setModel: EventId<T>;
/** identifier for the event to update the model by a given partial model */
updateModel: EventId<Partial<T>>;
/** identifier for the event to reset the model to the configured default */
resetModel: EventId<undefined>;

@@ -22,22 +23,21 @@ };

/**
* Type specifying the output signal ids produced by a ModelSignalsFactory.
* Type specifying the output signal ids produced by a {@link ModelSignalsFactory}.
*
* @typedef {object} ModelOutputSignals<T> - object holding the output signal identifiers for ModelSignals
* @template T - the type of the model to be handled
* @property {StateId<T>} model - identifier for the model behavior
*/
export type ModelOutputSignals<T> = {
model: BehaviorId<T>; // on purpose no StateId to keep encapsulation (BehaviorId cannot be used to add more reducers)
/** identifier for the model behavior (on purpose no StateId to keep encapsulation, cause BehaviorId cannot be used to add more reducers) */
model: BehaviorId<T>;
};
/**
* Type specifying the configuration of a ModelSignalsFactory.
* Type specifying the configuration of a {@link ModelSignalsFactory}.
*
* @typedef {object} ModelConfig<T> - object holding the configuration for ModelSignals
* @template T - the type of the model to be handled
* @property {T} defaultModel - the default model
* @property {string | undefined} nameExtension - optional string to be used as argument to calls of getBehaviorId and getEventId
*/
export type ModelConfig<T> = {
/** the default model */
defaultModel: T;
/** optional string to be used as argument to calls of getBehaviorId and getEventId */
nameExtension?: string;

@@ -76,5 +76,4 @@ };

/**
* This type specifies a generic SignalsFactory to handle arbitrary models.
* This type specifies a generic {@link SignalsFactory} to handle arbitrary models.
*
* @typedef {object} ModelSignalsFactory<T>
* @template T - specifies the type of the model

@@ -89,3 +88,3 @@ */

/**
* This function creates a ModelSignalsFactory<T>.
* This function creates a {@link ModelSignalsFactory}.
*

@@ -92,0 +91,0 @@ * @template T - specifies the type of the model

@@ -23,5 +23,3 @@ /* eslint-disable @typescript-eslint/no-use-before-define */

/**
* This type defines an object that maps identifier names to signal ids or nested NameToSignalIds.
*
* @typedef {object} NameToSignalId - maps strings on SignalId<any> | NameToSignalId
* This type defines an object that maps identifier names to {@link SignalId}s or nested {@link NameToSignalId}s.
*/

@@ -31,5 +29,3 @@ export type NameToSignalId = { [key: string]: SignalId<any> | NameToSignalId };

/**
* This type defines an object that maps identifier names to effect ids or nested NameToEffectIds.
*
* @typedef {object} NameToEffectId - maps strings on EffectId<any, any> | NameToSignalId
* This type defines an object that maps identifier names to {@link EffectId}s or nested {@link NameToEffectId}s.
*/

@@ -39,7 +35,6 @@ export type NameToEffectId = { [key: string]: EffectId<any, any> | NameToEffectId };

/**
* This type defines an object that holds input and output signal-ids of a Signals type.
* This type defines an object that holds input and output {@link SignalId}s of a {@link Signals} type.
*
* @template IN - NameToSignalId defining input signals-ids
* @template OUT - NameToSignalId defining output signals-ids
* @typedef {object} SignalIds - holds input- and output- NameToSignalId objects
* @template IN - {@link NameToSignalId} defining input signals-ids
* @template OUT - {@link NameToSignalId} defining output signals-ids
*/

@@ -52,6 +47,5 @@ export type SignalIds<IN extends NameToSignalId, OUT extends NameToSignalId> = {

/**
* This type defines an object that holds effect-ids of a Signals type.
* This type defines an object that holds {@link EffectId}s of a {@link Signals} type.
*
* @template EFF - NameToEffectId defining effect-ids
* @typedef {object} EffectIds - holds NameToEffectId object
* @template EFF - {@link NameToEffectId} defining effect-ids
*/

@@ -63,6 +57,4 @@ export type EffectIds<EFF extends NameToEffectId> = {

/**
* This type defines an object with a function 'setup' that takes a store instance
* This type defines an object with a function 'setup' that takes a {@link Store} instance
* as argument and executes the required setup (wireing) to produce certain output signals.
*
* @typedef {object} SetupWithStore - has a function setup(store) => void
*/

@@ -74,5 +66,5 @@ export type SetupWithStore = {

/**
* This type defines an immutable object that encapsulates SignalIds, SetupWithStore and EffectIds.
* The setup method creates all the necessary wireing to configure the store for the SignalIds.
* The Signals type represents the reactive counterpart to a class-instance (the IN/OUT-NameToSignalId
* This type defines an immutable object that encapsulates {@link SignalIds}, {@link SetupWithStore} and {@link EffectIds}.
* The setup method creates all the necessary wireing to configure the {@link Store} instance for the SignalIds.
* The Signals type represents the reactive counterpart to a class-instance (the IN/OUT-{@link NameToSignalId}
* being the counterpart to a class-interface).

@@ -82,6 +74,5 @@ * SetupWithStore must add sources to the store for all output-ids, but it must NOT add sources for

*
* @typedef {object} Signals<IN, OUT, EFF> - composition of SetupWithStore, SignalIds<IN, OUT> and EffectIds<EFF>
* @template IN - concrete NameToSignalIds defining input signal-ids. SetupWithStore does NOT add corresponding signals to the store (hence this must be done by the user of this Signals object, e.g. via connect)
* @template OUT - concrete NameToSignalIds defining output signal-ids. In contrast to the input signal-ids, the SetupWithStore method takes care of setting up corresponding signals in the store.
* @template EFF - concrete NameToEffectIds defining effect-ids. SetupWithStore does NOT add corresponding effects to the store (hence this must be done by the user of this Signals object)
* @template IN - concrete {@link NameToSignalId} defining input signal-ids. SetupWithStore does NOT add corresponding signals to the store (hence this must be done by the user of this Signals object, e.g. via connect)
* @template OUT - concrete {@link NameToSignalId} defining output signal-ids. In contrast to the input signal-ids, the SetupWithStore method takes care of setting up corresponding signals in the store.
* @template EFF - concrete {@link NameToEffectId} defining effect-ids. SetupWithStore does NOT add corresponding effects to the store (hence this must be done by the user of this Signals object)
*/

@@ -95,3 +86,3 @@ export type Signals<

/**
* This type defines a function taking some config-object as argument and returning a Signals object.
* This type defines a function taking some config-object as argument and returning a {@link Signals} object, hence the type being used as constructor argument for {@link SignalsFactory}.
* It creates input- and output-ids, as well as effect-ids.

@@ -101,11 +92,10 @@ * It is the reactive counterpart of a class/class-constructor.

* for the output-ids. For the input-ids, corresponding signals must be setup somewhere else (e.g. via store.connect).
* If you have a scenario, where setup needs a SignalId that is NOT created by SignalsBuild, then you can pass it via CONFIG.
* If you have a scenario, where setup needs a {@link SignalId} that is NOT created by {@link SignalsBuild}, then you can pass it via CONFIG.
* The same holds true for effects (no effects for the generated effect-ids will be added to the store).
* (see SignalsFactory::useExistingEffect on how to delegate from a generated effect-id to an existing effect)
* (see {@link SignalsFactory.useExistingEffect} on how to delegate from a generated effect-id to an existing effect)
*
* @typedef {function} SignalsBuild<IN, OUT, CONFIG, EFF> - constructor argument of SignalsFactories
* @template IN - concrete NameToSignalIds defining input signal-ids of the resulting Signals object
* @template OUT - concrete NameToSignalIds defining output signal-ids of the resulting Signals object
* @template CONFIG - concrete Configuration for the given SignalsBuild
* @template EFF - concrete NameToEffectIds defining effect-ids of the resulting Signals object
* @template IN - concrete {@link NameToSignalId} defining input signal-ids of the resulting Signals object
* @template OUT - concrete {@link NameToSignalId} defining output signal-ids of the resulting Signals object
* @template CONFIG - concrete {@link Configuration} for the given SignalsBuild
* @template EFF - concrete {@link NameToEffectId} defining effect-ids of the resulting Signals object
*/

@@ -120,14 +110,13 @@ export type SignalsBuild<

/**
* This type specifies a function mapping from SignalsBuild<IN1, OUT1, CONFIG1, EFF1> to a SignalsFactory<IN2, OUT2, CONFIG2, EFF2>,
* hence the argument to the monadic-bind method of a SignalsFactory<IN1, OUT1, CONFIG1, EFF1>.
* This type specifies a function mapping from ```SignalsBuild<IN1, OUT1, CONFIG1, EFF1>``` to ```SignalsFactory<IN2, OUT2, CONFIG2, EFF2>```,
* hence the argument to the monadic-bind method of a {@link SignalsFactory}.
*
* @typedef {function} BindMapper<IN1, OUT1, CONFIG1, EFF1, IN2, OUT2, CONFIG2, EFF2> - function mapping from SignalsBuild<IN1, OUT1, CONFIG1, EFF1> to SignalsFactory<IN2, OUT2, CONFIG2, EFF2>
* @template IN1 - concrete NameToSignalIds defining input-ids produced by the given SignalsBuild
* @template OUT1 - concrete NameToSignalIds defining output-ids produced by the given SignalsBuild
* @template CONFIG1 - concrete Configuration for the given SignalsBuild
* @template EFF1 - concrete NameToEffectIds defining effect-ids produced by the given SignalsBuild
* @template IN2 - concrete NameToSignalIds defining input signal-ids of the resulting SignalsFactory
* @template OUT2 - concrete NameToSignalIds defining output signal-ids of the resulting SignalsFactory
* @template CONFIG2 - concrete Configuration for the resulting SignalsFactory
* @template EFF2 - concrete NameToEffectIds defining effect-ids of the resulting SignalsFactory
* @template IN1 - concrete {@link NameToSignalId} defining input-ids produced by the given SignalsBuild
* @template OUT1 - concrete {@link NameToSignalId} defining output-ids produced by the given SignalsBuild
* @template CONFIG1 - concrete {@link Configuration} for the given SignalsBuild
* @template EFF1 - concrete {@link NameToEffectId} defining effect-ids produced by the given SignalsBuild
* @template IN2 - concrete {@link NameToSignalId} defining input signal-ids of the resulting SignalsFactory
* @template OUT2 - concrete {@link NameToSignalId} defining output signal-ids of the resulting SignalsFactory
* @template CONFIG2 - concrete {@link Configuration} for the resulting SignalsFactory
* @template EFF2 - concrete {@link NameToEffectId} defining effect-ids of the resulting SignalsFactory
*/

@@ -148,14 +137,13 @@ export type BindMapper<

/**
* This type specifies a function mapping from SignalsBuild<IN1, OUT1, CONFIG1, EFF1> to SignalsBuild<IN2, OUT2, CONFIG2, EFF2>,
* hence the argument to the functor-map-method of a SignalsFactory<IN1, OUT1, CONFIG1, EFF1>.
* This type specifies a function mapping from ```SignalsBuild<IN1, OUT1, CONFIG1, EFF1>``` to ```SignalsBuild<IN2, OUT2, CONFIG2, EFF2>```,
* hence the argument to the functor-map-method of a {@link SignalsFactory}.
*
* @typedef {function} BuildMapper<IN1, OUT1, CONFIG1, EFF1, IN2, OUT2, CONFIG2, EFF2> - function mapping from SignalsBuild<IN1, OUT1, CONFIG1, EFF1> to SignalsBuild<IN2, OUT2, CONFIG2, EFF2>
* @template IN1 - concrete NameToSignalIds defining input signal-ids produced by the given SignalsBuild<IN1, OUT1, CONFIG1, EFF1>
* @template OUT1 - concrete NameToSignalIds defining output signal-ids produced by the given SignalsBuild<IN1, OUT1, CONFIG1, EFF1>
* @template CONFIG1 - concrete Configuration for the given SignalsBuild<IN1, OUT1, CONFIG1, EFF1>
* @template EFF1 - concrete NameToEffectIds produced by the given SignalsBuild<IN1, OUT1, CONFIG1, EFF1>
* @template IN2 - concrete NameToSignalIds defining input signals-ids produced by the resulting SignalsBuild<IN2, OUT2, CONFIG2, EFF2>
* @template OUT2 - concrete NameToSignalIds defining output signal-ids produced by the resulting SignalsBuild<IN2, OUT2, CONFIG2, EFF2>
* @template CONFIG2 - concrete Configuration for the resulting SignalsBuild<IN2, OUT2, CONFIG2, EFF2>
* @template EFF2 - concrete NameToEffectIds produced by the resulting SignalsBuild<IN2, OUT2, CONFIG2, EFF2>
* @template IN1 - concrete {@link NameToSignalId} defining input signal-ids produced by the given SignalsBuild
* @template OUT1 - concrete {@link NameToSignalId} defining output signal-ids produced by the given SignalsBuild
* @template CONFIG1 - concrete {@link Configuration} for the given SignalsBuild
* @template EFF1 - concrete {@link NameToEffectId} produced by the given SignalsBuild
* @template IN2 - concrete {@link NameToSignalId} defining input signals-ids produced by the resulting SignalsBuild
* @template OUT2 - concrete {@link NameToSignalId} defining output signal-ids produced by the resulting SignalsBuild
* @template CONFIG2 - concrete {@link Configuration} for the resulting SignalsBuild
* @template EFF2 - concrete {@link NameToEffectId} produced by the resulting SignalsBuild
*/

@@ -176,13 +164,12 @@ export type BuildMapper<

/**
* This type specifies the result of the SignalsFactory compose method.
* This type specifies the result of the {@link SignalsFactory.compose} method.
*
* @typedef {object} ComposedFactory<IN1, OUT1, CONFIG1, EFF1, IN2, OUT2, CONFIG2, EFF2> - result of the composition of SignalsFactory<IN1, OUT1, CONFIG1, EFF1> and SignalsFactory<IN2, OUT2, CONFIG2, EFF2>
* @template IN1 - concrete NameToSignalIds defining input signal-ids of a SignalsFactory<IN1, OUT1, CONFIG1, EFF1>
* @template OUT1 - concrete NameToSignalIds defining output signal-ids of a SignalsFactory<IN1, OUT1, CONFIG1, EFF1>
* @template CONFIG1 - concrete Configuration of a SignalsFactory<IN1, OUT1, CONFIG1, EFF1>
* @template EFF1 - concrete NameToEffectIds of a SignalsFactory<IN1, OUT1, CONFIG1, EFF1>
* @template IN2 - concrete NameToSignalIds defining input signal-ids of a SignalsFactory<IN2, OUT2, CONFIG2, EFF2>
* @template OUT2 - concrete NameToSignalIds defining output signal-ids of a SignalsFactory<IN2, OUT2, CONFIG2, EFF2>
* @template CONFIG2 - concrete Configuration of a SignalsFactory<IN2, OUT2, CONFIG2, EFF2>
* @template EFF1 - concrete NameToEffectIds of a SignalsFactory<IN2, OUT2, CONFIG2, EFF2>
* @template IN1 - concrete {@link NameToSignalId} defining input signal-ids of SignalsFactory1
* @template OUT1 - concrete {@link NameToSignalId} defining output signal-ids of SignalsFactory1
* @template CONFIG1 - concrete {@link Configuration} of SignalsFactory1
* @template EFF1 - concrete {@link NameToEffectId} of SignalsFactory1
* @template IN2 - concrete {@link NameToSignalId} defining input signal-ids of SignalsFactory2
* @template OUT2 - concrete {@link NameToSignalId} defining output signal-ids of SignalsFactory2
* @template CONFIG2 - concrete {@link Configuration} of SignalsFactory2
* @template EFF1 - concrete {@link NameToEffectId} of SignalsFactory2
*/

@@ -206,9 +193,8 @@ export type ComposedFactory<

/**
* This type specifies the argument to the extendSetup-method of SignalFactories.
* This type specifies the argument to the {@link SignalsFactory.extendSetup} method.
*
* @typedef {function} ExtendSetup<IN, OUT, CONFIG> - function consuming store, input, output and configuration of a SignalsFactory
* @template IN - concrete NameToSignalIds defining input signal-ids of a SignalsFactory<IN, OUT, CONFIG, EFF>
* @template OUT - concrete NameToSignalIds defining output signal-ids of a SignalsFactory<IN, OUT, CONFIG, EFF>
* @template CONFIG - concrete Configuration of a SignalsFactory<IN, OUT, CONFIG, EFF>
* @template EFF - concrete NameToEffectIds of a SignalsFactory<IN, OUT, CONFIG, EFF>
* @template IN - concrete {@link NameToSignalId} defining input signal-ids of a SignalsFactory
* @template OUT - concrete {@link NameToSignalId} defining output signal-ids of a SignalsFactory
* @template CONFIG - concrete {@link Configuration} of a SignalsFactory
* @template EFF - concrete {@link NameToEffectId} of a SignalsFactory
*/

@@ -230,3 +216,3 @@ export type ExtendSetup<

/**
* Function mapping from one concrete NameToSignalId to another NameToSignalId
* Function mapping from one concrete {@link NameToSignalId} to another {@link NameToSignalId}
*/

@@ -239,3 +225,3 @@ export type MapSignalIds<T1 extends NameToSignalId, T2 extends NameToSignalId, CONFIG> = (

/**
* Function mapping from one concrete NameToEffectId to another NameToEffectId
* Function mapping from one concrete {@link NameToEffectId} to another {@link NameToEffectId}
*/

@@ -248,5 +234,9 @@ export type MapEffectIds<T1 extends NameToEffectId, T2 extends NameToEffectId, CONFIG> = (

/**
* AddSignalId is the result type of adding a key in a NameToSignalId.
* AddSignalId is the result type of adding a key in a {@link NameToSignalId} (also see the difference to {@link AddOrReplaceId}).
*
* @typedef {object} AddSignalId<T, N, ID> - the result of adding { [N]: ID; } on T
* ```ts
* AddSignalId<{ a: EventId<number> }, 'a', EventId<string> -> { a: EventId<never> }
* AddSignalId<{ a: EventId<number> }, 'b', EventId<string> -> { a: EventId<number>; b: EventId<string> }
* ```
*
* @template T - concrete NameToSignalIds

@@ -265,5 +255,10 @@ * @template N - string key

/**
* AddOrReplaceId is the result type of adding or replacing a key in a NameToSignalId.
* AddOrReplaceId is the result type of adding or replacing a key in a {@link NameToSignalId}.
*
* @typedef {object} AddOrReplaceId<T, N, ID> - the result of adding or replacing { [N]: ID; } on T
* ```ts
* AddOrReplaceId<{ a: EventId<number> }, 'a', EventId<string> -> { a: EventId<string> }
* AddOrReplaceId<{ a: EventId<number> }, 'b', EventId<string> -> { a: EventId<number>; b: EventId<string> }
* ```
*
* @typedef {object} AddOrReplaceId
* @template T - concrete NameToSignalIds

@@ -282,5 +277,9 @@ * @template N - string key

/**
* AddEffectId is the result type of adding a key in a NameToEffectId.
* AddEffectId is the result type of adding a key in a {@link NameToEffectId}.
*
* @typedef {object} AddEffectId<T, N, ID> - the result of adding { [N]: ID; } on T
* ```ts
* AddEffectId<{ a: EffectId<number, string> }, N, ID> -> { a: EffectId<number, string>; [N]: ID }
* ```
*
* @typedef {object} AddEffectId
* @template T - concrete NameToEffectIds

@@ -299,5 +298,9 @@ * @template N - string key

/**
* RenameId is the result type of renaming a key in a NameToSignalId.
* RenameId is the result type of renaming a key in a {@link NameToSignalId}.
*
* @typedef {object} RenameId<T extends NameToSignalId, N1 extends keyof T, N2 extends string> - the result type of { [N1]: T[N1]; } -> { [N2]: T[N1]; }
* ```ts
* RenameId<{ [N1]: T[N1] }> -> { [N2]: T[N1] }
* ```
*
* @typedef {object} RenameId
* @template T - concrete NameToSignalIds

@@ -315,5 +318,9 @@ * @template N1 - string old key

/**
* RenameEffectId is the result type of renaming a key in a NameToEffectId.
* RenameEffectId is the result type of renaming a key in a {@link NameToEffectId}.
*
* @typedef {object} RenameEffectId<T extends NameToEffectId, N1 extends keyof T, N2 extends string> - the result type of { [N1]: T[N1]; } -> { [N2]: T[N1]; }
* ```ts
* RenameEffectId<{ [N1]: T[N1] }, N1, N2> -> { [N2]: T[N1] }
* ```
*
* @typedef {object} RenameEffectId
* @template T - concrete NameToEffectIds

@@ -333,5 +340,5 @@ * @template N1 - string old key

* If K does extend keyof T (K is a key of the object T), then never | Message will be the result type.
* The latter would result in a TS-error, if a function expects an argument as AssertNonExistingKey<K, T, M>, saying "argument of type <K> is not assignable to parameter of type <Message>"
* The latter would result in a TS-error, if a function expects an argument as AssertNonExistingKey\<K, T, M\>, saying "argument of type \<K\> is not assignable to parameter of type \<Message\>"
*
* @typedef {object} AssertNonExistingKey<K, T, Message> - evaluates to K only if K is not in keyof T, else gives compile-time error including Message
* @typedef {object} AssertNonExistingKey - evaluates to K only if K is not in keyof T, else gives compile-time error including Message
* @template K - string

@@ -348,3 +355,3 @@ * @template T - object with string keys

/**
* The SignalsFactory wraps a SignalsBuild<IN, OUT, CONFIG, EFF> function, allowing for simple Signals composition
* A SignalsFactory wraps a {@link SignalsBuild} function, allowing for simple {@link Signals} composition
* and manipulation.

@@ -355,6 +362,6 @@ * Via the compose method, two SignalsFactories can be easily composed to a new one.

* compose, extendSetup, mapInput, mapOutput and mapConfig).
* SignalsFactory instances are immutable, hence all methods return a new SignalsFactory instance.
* SignalsFactory instances are immutable (persistent data structures), hence all methods return a new SignalsFactory instance.
* (The whole purpose of this class is to provide immutable SignalsBuild composition)
*
* @class SignalsFactory<IN extends NameToSignalId, OUT extends NameToSignalId, CONFIG extends Configuration = {}, EFF extends NameToEffectId = {}>
* @class SignalsFactory
*/

@@ -368,5 +375,5 @@ export class SignalsFactory<

/**
* The constructor takes a pure function implementing SignalsBuild<IN, OUT, CONFIG, EFF>.
* The constructor takes a pure function implementing SignalsBuild.
*
* @param {SignalsBuild<IN, OUT, CONFIG, EFF>} build - a pure function mapping from CONFIG to Signals<IN, OUT, EFF>
* @param {SignalsBuild<IN, OUT, CONFIG, EFF>} build - a pure function mapping from CONFIG to Signals
* @constructor

@@ -377,9 +384,9 @@ */

/**
* The compose method takes a second SignalsFactory<IN2, OUT2, CONFIG2, EFF2> and returns a new SignalsFactory
* that represents the composition of this SignalsFactory and the argument SignalsFactory<IN2, OUT2, CONFIG2, EFF2>.
* You can re-map the input, output, configuration and effects of the resulting ComposedFactory<IN, OUT, CONFIG, EFF, IN2, OUT2, CONFIG2, EFF2>
* The compose method takes a second SignalsFactory2 and returns a new SignalsFactory
* that represents the composition of this SignalsFactory and the argument SignalsFactory2.
* You can re-map the input, output, configuration and effects of the resulting composed SignalsFactory
* by using mapInput, mapOutput, mapConfig and mapEffects correspondingly (as well as the many other convenience methods).
*
* @param {SignalsFactory<IN2, OUT2, CONFIG2, EFF2>} factory2 - a SignalsFactory<IN2, OUT2, CONFIG2, EFF2>
* @returns {ComposedFactory<IN, OUT, CONFIG, EFF, IN2, OUT2, CONFIG2, EFF2>} - the SignalsFactory resulting from the composition of SignalsFactory<IN, OUT, CONFIG, EFF> and SignalsFactory<IN2, OUT2, CONFIG2, EFF2>
* @param {SignalsFactory} factory2 - a SignalsFactory
* @returns {SignalsFactory} - the SignalsFactory resulting from the composition of this SignalsFactory and SignalsFactory2
*/

@@ -422,9 +429,9 @@ compose<

* This method implements monadic-bind for the SignalsFactory.
* It takes as argument a pure function that implements SignalsMapToFactory<IN, OUT, CONFIG, EFF, IN2, OUT2, CONFIG2, EFF2>, hence
* a function taking SignalsBuild<IN, OUT, CONFIG, EFF> as argument and returning a SignalsFactory<IN2, OUT2, CONFIG2, EFF2>.
* The result of bind is a new SignalsFactory<IN2, OUT2, CONFIG2, EFF2> that uses the SignalsBuild<IN2, OUT2, CONFIG2, EFF2>::build
* It takes as argument a pure function that implements SignalsMapToFactory\<IN, OUT, CONFIG, EFF, IN2, OUT2, CONFIG2, EFF2\>, hence
* a function taking SignalsBuild\<IN, OUT, CONFIG, EFF\> as argument and returning a SignalsFactory\<IN2, OUT2, CONFIG2, EFF2\>.
* The result of bind is a new SignalsFactory that uses the SignalsBuild\<IN2, OUT2, CONFIG2, EFF2\>::build
* of the factory returned from the mapper (hence the result of bind is not the same instance as returned by the mapper).
*
* @param {BindMapper<IN, OUT, CONFIG, EFF, IN2, OUT2, CONFIG2, EFF2>} mapper - a pure function mapping from SignalsBuild<IN, OUT, CONFIG, EFF> to SignalsFactory<IN2, OUT2, CONFIG2, EFF2>
* @returns {SignalsFactory<IN2, OUT2, CONFIG2, EFF>} - a new SignalsFactory<IN2, OUT2, CONFIG2, EFF2>
* @param {BindMapper} mapper - a pure function mapping from SignalsBuild\<IN, OUT, CONFIG, EFF\> to SignalsFactory\<IN2, OUT2, CONFIG2, EFF2\>
* @returns {SignalsFactory} - a new SignalsFactory\<IN2, OUT2, CONFIG2, EFF2\>
*/

@@ -445,9 +452,9 @@ bind<

* This method implements the functor-fmap for the SignalsFactory.
* It takes as argument a pure function that implements BuildMapper<IN, OUT, CONFIG, EFF, IN2, OUT2, CONFIG2, EFF2>, hence
* a function taking SignalsBuild<IN, OUT, CONFIG, EFF> as argument and returning a SignalsBuild<IN2, OUT2, CONFIG2, EFF2>.
* The result of fmap is a new SignalsFactory<IN2, OUT2, CONFIG2, EFF2> that uses the SignalsBuild<IN2, OUT2, CONFIG2, EFF2> returned
* It takes as argument a pure function that implements BuildMapper\<IN, OUT, CONFIG, EFF, IN2, OUT2, CONFIG2, EFF2\>, hence
* a function taking SignalsBuild\<IN, OUT, CONFIG, EFF\> as argument and returning a SignalsBuild\<IN2, OUT2, CONFIG2, EFF2\>.
* The result of fmap is a new SignalsFactory that uses the SignalsBuild\<IN2, OUT2, CONFIG2, EFF2\> returned
* from the mapper.
*
* @param {BuildMapper<IN, OUT, CONFIG, EFF, IN2, OUT2, CONFIG2, EFF2>} mapper - a pure function mapping from SignalsBuild<IN, OUT, CONFIG, EFF> to SignalsBuild<IN2, OUT2, CONFIG2, EFF2>
* @returns {SignalsFactory<IN2, OUT2, CONFIG2, EFF2>} - a new SignalsFactory<IN2, OUT2, CONFIG2, EFF2>
* @param {BuildMapper} mapper - a pure function mapping from SignalsBuild\<IN, OUT, CONFIG, EFF\> to SignalsBuild\<IN2, OUT2, CONFIG2, EFF2\>
* @returns {SignalsFactory} - a new SignalsFactory\<IN2, OUT2, CONFIG2, EFF2\>
*/

@@ -467,8 +474,8 @@ fmap<

/**
* The extendSetup method takes as argument a function that implements ExtendSetup<IN, OUT, CONFIG, EFF>.
* The extendSetup method takes as argument a function that implements ExtendSetup\<IN, OUT, CONFIG, EFF\>.
* It returns a new SignalsFactory of the same type as this SignalsFactory, but with a wrapped SignalsBuild that
* extends the code executed in the Signals setup method by the provided code.
*
* @param {ExtendSetup<IN, OUT, CONFIG, EFF>} extend - a function extending the setup method of the Signals produced by the SignalsBuild of the resulting SignalsFactory
* @returns {SignalsFactory<IN, OUT, CONFIG, EFF>} - a new SignalsFactory with extended store setup
* @param {ExtendSetup} extend - a function extending the setup method of the Signals produced by the SignalsBuild of the resulting SignalsFactory
* @returns {SignalsFactory} - a new SignalsFactory with extended store setup
*/

@@ -492,13 +499,13 @@ extendSetup(extend: ExtendSetup<IN, OUT, CONFIG, EFF>): SignalsFactory<IN, OUT, CONFIG, EFF> {

* If keepInputId is set to true, it returns a new SignalsFactory of the same type as this SignalsFactory,
* but with an extended setup logic, that connects the Signal<S extends T> that corresponds to the named output-id to a
* new Signal<T> corresponding to the named input-id.
* but with an extended setup logic, that connects the Signal\<S extends T\> that corresponds to the named output-id to a
* new Signal\<T\> corresponding to the named input-id.
* If keepInputId is set to false, it also extends the setup logic to connect the corresponding signal-ids, but in addition
* the specified input-id will be excluded from the IN-type of the resulting factory.
* (also see store.connect documentation, as this is used under the hood)
* Typescript will enforce that both names (keys) map to compatible signal ids, hence if KIN corresponds to SignalId<T>,
* then KOUT must correspond to SignalId<S extends T> (though one might be an EventId and the other a BehaviorId).
* Typescript will enforce that both names (keys) map to compatible signal ids, hence if KIN corresponds to SignalId\<T\>,
* then KOUT must correspond to SignalId\<S extends T\> (though one might be an EventId and the other a BehaviorId).
* That is, even though you only use strings as arguments, this method is still type-safe and will not compile if you try to specify names of non-existing or incompatible ids.
*
* @param {KIN} inputName - a key of IN, where IN[toName] must be of type Signal<T>
* @param {KOUT} outputName - a key of OUT, where OUT[outputName] must be of type Signal<S extends T>
* @param {KIN} inputName - a key of IN, where IN\[toName\] must be of type Signal\<T\>
* @param {KOUT} outputName - a key of OUT, where OUT\[outputName\] must be of type Signal\<S extends T\>
* @param {boolean} keepInputId - if set to false, the input-id corresponding to toName will be removed from the resulting factories' IN

@@ -534,4 +541,4 @@ * @returns {SignalsFactory} - a new SignalsFactory with the concrete type depending on the keepInputId argument

*
* @param {KIN} inputName - a key of IN, where IN[toName] must be of type Signal<T>
* @param {ID} fromId - a Signal<S extends T>
* @param {KIN} inputName - a key of IN, where IN\[toName\] must be of type Signal\<T\>
* @param {ID} fromId - a Signal\<S extends T\>
* @param {boolean} keepInputId - if set to false, the input-id corresponding to toName will be removed from the resulting factories' IN

@@ -562,4 +569,4 @@ * @returns {SignalsFactory} - a new SignalsFactory with the concrete type depending on the keepInputId argument

*
* @param {KIN} inputName - a key of IN, where IN[toName] must be of type Signal<T>
* @param {function} sourceGetter - a function returning an Observable<S extends T>
* @param {KIN} inputName - a key of IN, where IN\[toName\] must be of type Signal\<T\>
* @param {function} sourceGetter - a function returning an Observable\<S extends T\>
* @param {boolean} keepInputId - if set to false, the input-id corresponding to toName will be removed from the resulting factories' IN

@@ -591,7 +598,7 @@ * @returns {SignalsFactory} - a new SignalsFactory with the concrete type depending on the keepInputId argument

/**
* The mapConfig method takes as argument a pure function that implements MapConfig<CONFIG, CONFIG2>.
* It returns a new SignalsFactory<IN, OUT, CONFIG2, EFF>.
* The mapConfig method takes as argument a pure function that implements MapConfig\<CONFIG, CONFIG2\>.
* It returns a new SignalsFactory\<IN, OUT, CONFIG2, EFF\>.
*
* @param {MapConfig<CONFIG, CONFIG2>} mapper - a pure function mapping CONFIG2 to CONFIG
* @returns {SignalsFactory<IN, OUT, CONFIG2, EFF>} - a new SignalsFactory with different Configuration type
* @param {MapConfig} mapper - a pure function mapping CONFIG2 to CONFIG
* @returns {SignalsFactory} - a new SignalsFactory with different Configuration type
*/

@@ -606,7 +613,7 @@ mapConfig<CONFIG2 extends Configuration>(

/**
* The mapInput method takes as argument a pure function that implements MapSignalIds<IN, IN2>.
* It returns a new SignalsFactory<IN2, OUT, CONFIG, EFF>.
* The mapInput method takes as argument a pure function that implements MapSignalIds\<IN, IN2\>.
* It returns a new SignalsFactory\<IN2, OUT, CONFIG, EFF\>.
*
* @param {MapSignalIds<IN, IN2, CONFIG>} mapper - a pure function mapping from IN to IN2
* @returns {SignalsFactory<IN2, OUT, CONFIG, EFF>} - a new SignalsFactory with different input signals
* @param {MapSignalIds} mapper - a pure function mapping from IN to IN2
* @returns {SignalsFactory} - a new SignalsFactory with different input signals
*/

@@ -632,4 +639,4 @@ mapInput<IN2 extends NameToSignalId>(

* @param {K} name - the name of the new SignalId
* @param {() => ID} idGetter - a function returning the new SignalId
* @returns {SignalsFactory<AddSignalId<IN, K, ID>, OUT, CONFIG, EFF>} - a new SignalsFactory with modified input signals
* @param {function} idGetter - a function returning the new SignalId
* @returns {SignalsFactory} - a new SignalsFactory with modified input signals
*/

@@ -651,6 +658,6 @@ addInputId<K extends string, ID extends SignalId<any>>(

* @template K1 - a concrete key of IN
* @template K2 - the new name for IN[K1]
* @template K2 - the new name for IN\[K1\]
* @param {K1} oldName - the old key
* @param {K2} newName - the new key
* @returns {SignalsFactory<RenameId<IN, K1, K2>, OUT, CONFIG, EFF>} - a new SignalsFactory with modified input signals
* @returns {SignalsFactory} - a new SignalsFactory with modified input signals
*/

@@ -677,3 +684,3 @@ renameInputId<K1 extends keyof IN, K2 extends string>(

* @param {K} name - the name of the SignalId to be removed
* @returns {SignalsFactory<Omit<IN, K>, OUT, CONFIG, EFF>} - a new SignalsFactory with modified input signals
* @returns {SignalsFactory} - a new SignalsFactory with modified input signals
*/

@@ -689,7 +696,7 @@ removeInputId<K extends keyof IN>(name: K): SignalsFactory<Omit<IN, K>, OUT, CONFIG, EFF> {

/**
* The mapOutput method takes as argument a pure function that implements MapSignalIds<OUT, OUT2>.
* It returns a new SignalsFactory<IN, OUT2, CONFIG, EFF>.
* The mapOutput method takes as argument a pure function that implements MapSignalIds\<OUT, OUT2\>.
* It returns a new SignalsFactory\<IN, OUT2, CONFIG, EFF\>.
*
* @param {MapSignalIds<OUT, OUT2>} mapper - a pure function mapping from OUT to OUT2
* @returns {SignalsFactory<IN, OUT2, CONFIG, EFF>} - a new SignalsFactory with different output signals
* @param {MapSignalIds} mapper - a pure function mapping from OUT to OUT2
* @returns {SignalsFactory} - a new SignalsFactory with different output signals
*/

@@ -715,4 +722,4 @@ mapOutput<OUT2 extends NameToSignalId>(

* @param {K} name - the name of the new SignalId
* @param {() => ID} idGetter - a function returning the new SignalId
* @returns {SignalsFactory<IN, AddOrReplaceId<OUT, K, ID>, CONFIG, EFF>} - a new SignalsFactory with modified output signals
* @param {function} idGetter - a function returning the new SignalId
* @returns {SignalsFactory} - a new SignalsFactory with modified output signals
*/

@@ -734,6 +741,6 @@ addOutputId<K extends string, ID extends SignalId<any>>(

* @template K1 - a concrete key of OUT
* @template K2 - the new name for OUT[K1]
* @template K2 - the new name for OUT\[K1\]
* @param {K1} oldName - the old key
* @param {K2} newName - the new key
* @returns {SignalsFactory<IN, RenameId<OUT, K1, K2>, CONFIG, EFF>} - a new SignalsFactory with modified output signals
* @returns {SignalsFactory} - a new SignalsFactory with modified output signals
*/

@@ -760,3 +767,3 @@ renameOutputId<K1 extends keyof OUT, K2 extends string>(

* @param {K} name - the name of the SignalId to be removed
* @returns {SignalsFactory<IN, Omit<OUT, K>, CONFIG, EFF>} - a new SignalsFactory with modified output signals
* @returns {SignalsFactory} - a new SignalsFactory with modified output signals
*/

@@ -776,10 +783,10 @@ removeOutputId<K extends keyof OUT>(name: K): SignalsFactory<IN, Omit<OUT, K>, CONFIG, EFF> {

* new behavior into output under the removed name of the existing behavior.
* Hence, this transforms from SignalsFactory<IN, OUT, CONFIG> to SignalsFactory<IN, OUT2, CONFIG>
* with OUT2 having the same keys as OUT, but OUT2[KOUT] having type TNEW and OUT[KOUT] having type TOLD
* Hence, this transforms from SignalsFactory\<IN, OUT, CONFIG\> to SignalsFactory\<IN, OUT2, CONFIG\>
* with OUT2 having the same keys as OUT, but OUT2\[KOUT\] having type TNEW and OUT\[KOUT\] having type TOLD
*
* @template KOUT - a concrete output key mapping to a BehaviorId<any>
* @template TNEW - value-type of the OUT2[KOUT] BehaviorId after mapping
* @param {KOUT} outputName - the name of a BehaviorId<any> from OUT
* @param {function} mapper - a function returning Observable<TNEW>
* @returns {SignalsFactory<IN, AddOrReplaceId<OUT, KOUT, BehaviorId<TNEW>>, CONFIG, EFF>} - a new SignalsFactory with a modified output signal
* @template TNEW - value-type of the OUT2\[KOUT\] BehaviorId after mapping
* @param {KOUT} outputName - the name of a BehaviorId\<any\> from OUT
* @param {function} mapper - a function returning Observable\<TNEW\>
* @returns {SignalsFactory} - a new SignalsFactory with a modified output signal
*/

@@ -818,7 +825,7 @@ mapOutputBehavior<TNEW, KOUT extends keyof WithValueType<OUT, BehaviorId<any>>>(

/**
* The mapEffects method takes as argument a pure function that implements MapEffectIds<EFF, EFF2, CONFIG>.
* It returns a new SignalsFactory<IN, OUT, CONFIG, EFF2>.
* The mapEffects method takes as argument a pure function that implements MapEffectIds\<EFF, EFF2, CONFIG\>.
* It returns a new SignalsFactory\<IN, OUT, CONFIG, EFF2\>.
*
* @param {MapSignalIds<EFF, EFF2>} mapper - a pure function mapping from EFF to EFF2
* @returns {SignalsFactory<IN, OUT, CONFIG, EFF2>} - a new SignalsFactory with different effect-ids
* @param {MapSignalIds} mapper - a pure function mapping from EFF to EFF2
* @returns {SignalsFactory} - a new SignalsFactory with different effect-ids
*/

@@ -844,4 +851,4 @@ mapEffects<EFF2 extends NameToEffectId>(

* @param {K} name - the name of the new EffectId
* @param {() => ID} idGetter - a function returning the new EffectId
* @returns {SignalsFactory<IN, OUT, CONFIG, AddEffectId<EFF, K, ID>>} - a new SignalsFactory with modified effect-ids
* @param {function} idGetter - a function returning the new EffectId
* @returns {SignalsFactory} - a new SignalsFactory with modified effect-ids
*/

@@ -864,3 +871,3 @@ addEffectId<K extends string, ID extends EffectId<any, any>>(

* @param {K} name - the name of in NameToEffectIds to be removed
* @returns {SignalsFactory<IN, OUT, CONFIG, Omit<EFF, K>>} - a new SignalsFactory with modified effect-ids
* @returns {SignalsFactory} - a new SignalsFactory with modified effect-ids
*/

@@ -918,3 +925,3 @@ removeEffectId<K extends keyof EFF>(name: K): SignalsFactory<IN, OUT, CONFIG, Omit<EFF, K>> {

* @param {K2} newName - the new key
* @returns {SignalsFactory<IN, OUT, CONFIG, RenameEffectId<EFF, K1, K2>>} - a new SignalsFactory with modified effect-ids
* @returns {SignalsFactory} - a new SignalsFactory with modified effect-ids
*/

@@ -921,0 +928,0 @@ renameEffectId<K1 extends keyof EFF, K2 extends string>(

@@ -5,2 +5,5 @@ import { Observable, Subject, Subscription } from 'rxjs';

/**
* @internal
*/
export class SourceObservable<T> {

@@ -7,0 +10,0 @@ private subscription: Subscription | null = null;

import { Observable } from 'rxjs';
/**
* The rx-signals Store uses this type to uniquely identify behaviors representing a root-state behavior.
* A StateId<T> does not make any use of the generic T itself, but is given this
* The rx-signals {@link Store} uses this type to uniquely identify behaviors representing a root-state behavior.
* A StateId\<T\> does not make any use of the generic T itself, but is given this
* parameter only as a trick to let Typescript infer and thus enforce the correct types.
* Use the getStateId<T>() function to generate a corresponding ID.
* Use the {@link getStateId} function to generate a corresponding ID.
*
* @typedef {object} StateId<T> - type to uniquely identify a certain root-state behavior
* @template T - specifies the type for the corresponding behavior observable
* @property {symbol} symbol - a symbol, making the StateId unique
* @template T - specifies the value-type for the corresponding behavior observable (type of the state)
*/

@@ -18,10 +16,8 @@ export type StateId<T> = symbol & {

/**
* The rx-signals Store uses this type to uniquely identify behaviors representing a derived-state behavior.
* A StateId<T> does not make any use of the generic T itself, but is given this
* The rx-signals {@link Store} uses this type to uniquely identify behaviors representing a derived-state behavior.
* A StateId\<T\> does not make any use of the generic T itself, but is given this
* parameter only as a trick to let Typescript infer and thus enforce the correct types.
* Use the getDerivedId<T>() function to generate a corresponding ID.
* Use the {@link getDerivedId} function to generate a corresponding ID.
*
* @typedef {object} DerivedId<T> - type to uniquely identify a certain derived-state behavior
* @template T - specifies the type for the corresponding behavior observable
* @property {symbol} symbol - a symbol, making the DerivedId unique
* @template T - specifies the value-type for the corresponding behavior observable
*/

@@ -33,6 +29,5 @@ export type DerivedId<T> = symbol & {

/**
* The rx-signals Store uses this type for cases where either a StateId or a DerivedId is expected.
* The rx-signals {@link Store} uses this type for cases where either a {@link StateId} or a {@link DerivedId} is expected.
*
* @typedef {object} BehaviorId<T> - type to uniquely identify a certain behavior
* @template T - specifies the type for the corresponding behavior observable
* @template T - specifies the value-type for the corresponding behavior observable
*/

@@ -42,10 +37,8 @@ export type BehaviorId<T> = StateId<T> | DerivedId<T>;

/**
* The rx-signals Store uses this type to uniquely identify all of its events.
* An EventId<T> does not make any use of the generic T itself, but is given this
* The rx-signals {@link Store} uses this type to uniquely identify all of its events.
* An EventId\<T\> does not make any use of the generic T itself, but is given this
* parameter only as a trick to let Typescript infer and thus enforce the correct types.
* Use the getEventId<T>() function to generate a corresponding ID.
* Use the {@link getEventId} function to generate a corresponding ID.
*
* @typedef {object} EventId<T> - type to uniquely identify a certain event
* @template T - specifies the type for the corresponding event observable
* @property {symbol} symbol - a symbol, making the EventId unique
* @template T - specifies the value-type for the corresponding event observable
*/

@@ -57,9 +50,8 @@ export type EventId<T> = symbol & {

/**
* SignalId<T> is the union type of BehaviorId<T> and EventId<T>, hence it
* SignalId\<T\> is the union type of BehaviorId\<T\> and EventId\<T\>, hence it
* represents an identifier that corresponds either to a behavior or to an event.
* You can use the functions isBehaviorId or isEventId to check the concrete
* You can use the functions {@link isBehaviorId} or {@link isEventId} to check the concrete
* type of a SignalId.
*
* @typedef {object} EventId<T> - type to uniquely identify a certain event
* @template T - specifies the type for the corresponding event observable
* @template T - specifies the value-type for the corresponding observable
*/

@@ -69,11 +61,12 @@ export type SignalId<T> = BehaviorId<T> | EventId<T>;

/**
* ToSignalId<S> is a utility type that equals Signal<T>, if S extends SignalId<T>, else never.
* Examples:
* ToSignalId<BehaviorId<number>> would be SignalId<number>
* ToSignalId<EventId<string>> would be SignalId<string>
* ToSignalId<number> would be never
* ToSignalId\<S\> is a utility type that equals Signal\<T\>, if S extends SignalId\<T\>, else never.
*
* @typedef {object} SignalId<T> | never - the resulting type
* ```ts
* ToSignalId<BehaviorId<number>> = SignalId<number>
* ToSignalId<EventId<string>> = SignalId<string>
* ToSignalId<number> = never
* ```
*
* @template S - the generic argument to ToSignalId
* @template T - the inferred generic parameter of S, if S extends SignalId<T>
* @template T - the inferred generic parameter of S, if S extends SignalId\<T\>
*/

@@ -83,10 +76,11 @@ export type ToSignalId<S> = S extends SignalId<infer T> ? SignalId<T> : never;

/**
* ToBehaviorIdValueType<B> is a utility type that equals T, if B extends BehaviorId<T>, else never.
* Examples:
* ToBehaviorIdValueType<BehaviorId<number>> would be number
* ToBehaviorIdValueType<EventId<string>> would be never
* ToBehaviorIdValueType\<B\> is a utility type that equals T, if B extends BehaviorId\<T\>, else never.
*
* @typedef {T | never} T | never - the resulting type
* ```ts
* ToBehaviorIdValueType<BehaviorId<number>> = number
* ToBehaviorIdValueType<EventId<string>> = never
* ```
*
* @template B - the generic argument to ToBehaviorIdValueType
* @template T - the inferred generic parameter of B, if B extends BehaviorId<T>
* @template T - the inferred generic parameter of B, if B extends BehaviorId\<T\>
*/

@@ -96,10 +90,11 @@ export type ToBehaviorIdValueType<B> = B extends BehaviorId<infer T> ? T : never;

/**
* ToEventIdValueType<E> is a utility type that equals T, if E extends EventId<T>, else never.
* Examples:
* ToEventIdValueType<EventId<number>> would be number
* ToEventIdValueType<BehaviorId<string>> would be never
* ToEventIdValueType\<E\> is a utility type that equals T, if E extends EventId\<T\>, else never.
*
* @typedef {T | never} T | never - the resulting type
* ```ts
* ToEventIdValueType<EventId<number>> = number
* ToEventIdValueType<BehaviorId<string>> = never
* ```
*
* @template E - the generic argument to ToEventIdValueType
* @template T - the inferred generic parameter of E, if E extends EventId<T>
* @template T - the inferred generic parameter of E, if E extends EventId\<T\>
*/

@@ -109,11 +104,12 @@ export type ToEventIdValueType<E> = E extends EventId<infer T> ? T : never;

/**
* ToSignalIdValueType<S> is a utility type that equals T, if S extends SignalId<T>, else never.
* Examples:
* ToSignalIdValueType<EventId<number>> would be number
* ToSignalIdValueType<EventId<string>> would be string
* ToSignalIdValueType<number> would be never
* ToSignalIdValueType\<S\> is a utility type that equals T, if S extends SignalId\<T\>, else never.
*
* @typedef {T | never} T | never - the resulting type
* ```ts
* ToSignalIdValueType<EventId<number>> = number
* ToSignalIdValueType<EventId<string>> = string
* ToSignalIdValueType<number> = never
* ```
*
* @template S - the generic argument to ToSignalIdValueType
* @template T - the inferred generic parameter of S, if S extends SignalId<T>
* @template T - the inferred generic parameter of S, if S extends SignalId\<T\>
*/

@@ -123,11 +119,12 @@ export type ToSignalIdValueType<S> = S extends SignalId<infer T> ? T : never;

/**
* ToObservableValueType<O> is a utility type that equals T, if O extends Observable<T>, else never.
* Examples:
* ToObservableValueType<Observable<number>> would be number
* ToObservableValueType<Observable<string>> would be string
* ToObservableValueType<number> would be never
* ToObservableValueType\<O\> is a utility type that equals T, if O extends Observable\<T\>, else never.
*
* @typedef {T | never} T | never - the resulting type
* ```ts
* ToObservableValueType<Observable<number>> = number
* ToObservableValueType<Observable<string>> = string
* ToObservableValueType<number> = never
* ```
*
* @template O - the generic argument to ToObservableValueType
* @template T - the inferred generic parameter of O, if O extends Observable<T>
* @template T - the inferred generic parameter of O, if O extends Observable\<T\>
*/

@@ -138,10 +135,8 @@ export type ToObservableValueType<O> = O extends Observable<infer T> ? T : never;

* The rx-signals Store uses this type to uniquely identify all of its result effects.
* An EffectId<InputType, ResultType> does not make any use of the generic parameters itself,
* An EffectId\<InputType, ResultType\> does not make any use of the generic parameters itself,
* but is given these parameters only as a trick to let Typescript infer and thus enforce the correct types.
* Use the getEffectId<InputType, ResultType>() function to generate a corresponding ID.
* Use the {@link getEffectId} function to generate a corresponding ID.
*
* @typedef {object} EffectId<InputType, ResultType> - type to uniquely identify a certain result effect
* @template InputType - specifies the type for the corresponding effects input
* @template ResultType - specifies the type for the corresponding effects result
* @property {symbol} symbol - a symbol, making the EffectId unique
*/

@@ -161,4 +156,4 @@ export type EffectId<InputType, ResultType> = symbol & {

*
* @template T - specifies the type for the corresponding behavior
* @param {string} nameExtension - an optional extension to the symbol name (so the string representation). Usually, you don't need this, cause even for debugging purposes, you should use store.setIdName/getIdName.
* @template T - specifies the value-type for the corresponding behavior
* @param {string} nameExtension - an optional extension to the symbol name (so the string representation). Usually, you don't need this, cause even for debugging purposes, you should use {@link Store.setIdName} and {@link Store.getIdName}.
* @returns {StateId<T>}

@@ -172,4 +167,4 @@ */

*
* @template T - specifies the type for the corresponding behavior
* @param {string} nameExtension - an optional extension to the symbol name (so the string representation). Usually, you don't need this, cause even for debugging purposes, you should use store.setIdName/getIdName.
* @template T - specifies the value-type for the corresponding behavior
* @param {string} nameExtension - an optional extension to the symbol name (so the string representation). Usually, you don't need this, cause even for debugging purposes, you should use {@link Store.setIdName} and {@link Store.getIdName}.
* @returns {DerivedId<T>}

@@ -183,4 +178,4 @@ */

*
* @template T - specifies the type for the corresponding event
* @param {string} nameExtension - an optional extension to the symbol name (so the string representation). Usually, you don't need this, cause even for debugging purposes, you should use store.setIdName/getIdName.
* @template T - specifies the value-type for the corresponding event
* @param {string} nameExtension - an optional extension to the symbol name (so the string representation). Usually, you don't need this, cause even for debugging purposes, you should use {@link Store.setIdName} and {@link Store.getIdName}.
* @returns {EventId<T>}

@@ -187,0 +182,0 @@ */

@@ -1,7 +0,13 @@

import { asyncScheduler, BehaviorSubject, merge, NEVER, Observable, of } from 'rxjs';
import {
asyncScheduler,
BehaviorSubject,
delay,
distinctUntilChanged,
filter,
firstValueFrom,
map,
merge,
NEVER,
Observable,
of,
share,

@@ -11,3 +17,3 @@ switchMap,

withLatestFrom,
} from 'rxjs/operators';
} from 'rxjs';
import { ControlledSubject } from './controlled-subject';

@@ -33,11 +39,8 @@ import { DelayedEventQueue } from './delayed-event-queue';

/**
* The rx-signals Store uses the TypedEvent<T> to bundle certain events and their
* corresponding EventId<T>. This is used for EventSources that can dispatch events
* The {@link Store} uses the TypedEvent\<T\> to bundle certain events and their
* corresponding EventId\<T\>. This is used for EventSources that can dispatch events
* of different types (see addXTypedEventSource methods) or for cases where you want to
* subscribe multiple events and need to differentiate between them at runtime.
*
* @typedef {object} TypedEvent<T> - type for an object bundling identifier and corresponding event.
* @template T - specifies the type for the corresponding EventId<T>
* @property {EventId<T>} type - the EventId for the event
* @property {T} event - the event itself
* @template T - specifies the type for the corresponding event-values
*/

@@ -50,11 +53,7 @@ export type TypedEvent<T> = Readonly<{

/**
* The state reducer type specifies the signature for reducers used by the store.
* The state reducer type specifies the signature for reducers used by the {@link Store}.
* StateReducers must be pure functions.
*
* @typedef {function} StateReducer<T, E> - type for a pure function that takes a state and an event and returns a new state
* @template T - representing the type of the state
* @template E - representing the type of the event
* @property {T} state - the current state
* @property {E} event - the event
* @returns {T} - the new state
*/

@@ -65,9 +64,9 @@ export type StateReducer<T, E> = (state: T, event: E) => T;

* A LifecycleHandle can be used to control signals and signal-sources that
* are added to the store by store.getLifecycleHandle
*
* @property {function} reset - reset all behaviors corresponding to this lifecycle
* @property {function} end - remove all sources of this lifecycle and complete all corresponding behaviors (event-subscribers will NOT get a complete!)
* are added to the {@link Store} by store.getLifecycleHandle
*/
export type LifecycleHandle = {
/** reset all behaviors corresponding to this lifecycle */
reset: () => void;
/** reset all behaviors corresponding to this lifecycle */
end: () => void;

@@ -77,6 +76,6 @@ };

/**
* The Effect type specifies a potentially impure function that takes an input and the store as arguments
* The Effect type specifies a potentially impure function that takes an input and a {@link Store} as arguments
* and returns an effectful result as Observable.
* It is the low-level abstraction used by rx-signals for side-effect isolation.
* The high-level abstraction EffectSignalsFactory takes an EffectId as configuration to access
* The high-level abstraction {@link EffectSignalsFactory} takes an EffectId as configuration to access
* the corresponding Effect.

@@ -88,14 +87,16 @@ * The store argument can be used to access additional input from the store (thus, the Effect itself could also

*
* @typedef {function} Effect<Input, Result> - function performing an effect and returning an observable with the result
* @template Input - specifies the input type for the effect
* @template Result - specifies the result type for the effect
* @property {Input} input - the effect input
* @property {Store} store - the Store instance that will be passed to the function (e.g. to inject some other Effect).
* @property {Input | undefined} previousInput - the input of the previous function invocation, or undefined
* @property {Result | undefined} previousResult - the result of the previous function invocation, or undefined
*/
export type Effect<Input, Result> = (
/** the effect input */
input: Input,
/** the Store instance that will be passed to the function (e.g. to inject some other Effect) */
store: Store,
/** the input of the previous function invocation, or undefined */
previousInput?: Input,
/** the result of the previous function invocation, or undefined */
previousResult?: Result,

@@ -105,4 +106,4 @@ ) => Observable<Result>;

/**
* The rx-signals Store provides RxJs-Observables for RP (reactive programming) BehaviorStreams
* and EventStreams (behaviors and events are the two different types of signals, where behaviors represent state).
* The rx-signals Store provides RxJs-Observables for RP (reactive programming) - BehaviorStreams
* and EventStreams (behaviors and events are the two different types of signals, where behaviors represent immutable state).
* The Store separates the sources of these streams from the streams itself.

@@ -418,3 +419,3 @@ *

* This method takes a callback that performs Store operations.
* It returns a LifecycleHandle that can be used to reset or end the lifecycle of signals
* It returns a {@link LifecycleHandle} that can be used to reset or end the lifecycle of signals
* and signal-sources that are added to the store during the callback execution.

@@ -506,4 +507,2 @@ *

* Technically, this is done by first removing all sources and then adding them again.
*
* @returns {void} - the behavior observable (shared and distinct)
*/

@@ -540,4 +539,4 @@ resetBehaviors(): void {

if (controlledSubject.isObservableSubscribed()) {
const result: Promise<boolean> = this.getEventStream(identifier)
.pipe(
const result: Promise<boolean> = firstValueFrom(
this.getEventStream(identifier).pipe(
filter(val => val === event),

@@ -547,4 +546,4 @@ take(1),

delay(1, asyncScheduler),
)
.toPromise() as Promise<boolean>;
),
);
controlledSubject.next(event);

@@ -557,3 +556,3 @@ return result;

/**
* This method adds an event source to the Store. There can be multiple sources
* This method adds an event source to the store. There can be multiple sources
* for the same event type. However, each source must be identified by its own

@@ -750,10 +749,20 @@ * symbol and adding two sources with the same symbol would result in an error.

*/
add5TypedEventSource<A, B, C, D, E>(
eventIdentifierA: EventId<A>,
eventIdentifierB: EventId<B>,
eventIdentifierC: EventId<C>,
eventIdentifierD: EventId<D>,
eventIdentifierE: EventId<E>,
add5TypedEventSource<
IDA extends EventId<any>,
IDB extends EventId<any>,
IDC extends EventId<any>,
IDD extends EventId<any>,
IDE extends EventId<any>,
>(
eventIdentifierA: IDA,
eventIdentifierB: IDB,
eventIdentifierC: IDC,
eventIdentifierD: IDD,
eventIdentifierE: IDE,
observable: Observable<
TypedEvent<A> | TypedEvent<B> | TypedEvent<C> | TypedEvent<D> | TypedEvent<E>
| TypedEvent<ToEventIdValueType<IDA>>
| TypedEvent<ToEventIdValueType<IDB>>
| TypedEvent<ToEventIdValueType<IDC>>
| TypedEvent<ToEventIdValueType<IDD>>
| TypedEvent<ToEventIdValueType<IDE>>
>,

@@ -767,7 +776,27 @@ subscribeObservableOnlyIfEventIsSubscribed: EventId<any> | null = null,

);
this.addTypedEventSource(sourceId, eventIdentifierA, sharedSource as Observable<TypedEvent<A>>);
this.addTypedEventSource(sourceId, eventIdentifierB, sharedSource as Observable<TypedEvent<B>>);
this.addTypedEventSource(sourceId, eventIdentifierC, sharedSource as Observable<TypedEvent<C>>);
this.addTypedEventSource(sourceId, eventIdentifierD, sharedSource as Observable<TypedEvent<D>>);
this.addTypedEventSource(sourceId, eventIdentifierE, sharedSource as Observable<TypedEvent<E>>);
this.addTypedEventSource(
sourceId,
eventIdentifierA,
sharedSource as Observable<TypedEvent<ToEventIdValueType<IDA>>>,
);
this.addTypedEventSource(
sourceId,
eventIdentifierB,
sharedSource as Observable<TypedEvent<ToEventIdValueType<IDB>>>,
);
this.addTypedEventSource(
sourceId,
eventIdentifierC,
sharedSource as Observable<TypedEvent<ToEventIdValueType<IDC>>>,
);
this.addTypedEventSource(
sourceId,
eventIdentifierD,
sharedSource as Observable<TypedEvent<ToEventIdValueType<IDD>>>,
);
this.addTypedEventSource(
sourceId,
eventIdentifierE,
sharedSource as Observable<TypedEvent<ToEventIdValueType<IDE>>>,
);
if (this.currentLifecycleObjects !== null) {

@@ -792,11 +821,23 @@ this.currentLifecycleObjects.events.push(sourceId);

*/
add6TypedEventSource<A, B, C, D, E, F>(
eventIdentifierA: EventId<A>,
eventIdentifierB: EventId<B>,
eventIdentifierC: EventId<C>,
eventIdentifierD: EventId<D>,
eventIdentifierE: EventId<E>,
eventIdentifierF: EventId<F>,
add6TypedEventSource<
IDA extends EventId<any>,
IDB extends EventId<any>,
IDC extends EventId<any>,
IDD extends EventId<any>,
IDE extends EventId<any>,
IDF extends EventId<any>,
>(
eventIdentifierA: IDA,
eventIdentifierB: IDB,
eventIdentifierC: IDC,
eventIdentifierD: IDD,
eventIdentifierE: IDE,
eventIdentifierF: IDF,
observable: Observable<
TypedEvent<A> | TypedEvent<B> | TypedEvent<C> | TypedEvent<D> | TypedEvent<E> | TypedEvent<F>
| TypedEvent<ToEventIdValueType<IDA>>
| TypedEvent<ToEventIdValueType<IDB>>
| TypedEvent<ToEventIdValueType<IDC>>
| TypedEvent<ToEventIdValueType<IDD>>
| TypedEvent<ToEventIdValueType<IDE>>
| TypedEvent<ToEventIdValueType<IDF>>
>,

@@ -810,8 +851,32 @@ subscribeObservableOnlyIfEventIsSubscribed: EventId<any> | null = null,

);
this.addTypedEventSource(sourceId, eventIdentifierA, sharedSource as Observable<TypedEvent<A>>);
this.addTypedEventSource(sourceId, eventIdentifierB, sharedSource as Observable<TypedEvent<B>>);
this.addTypedEventSource(sourceId, eventIdentifierC, sharedSource as Observable<TypedEvent<C>>);
this.addTypedEventSource(sourceId, eventIdentifierD, sharedSource as Observable<TypedEvent<D>>);
this.addTypedEventSource(sourceId, eventIdentifierE, sharedSource as Observable<TypedEvent<E>>);
this.addTypedEventSource(sourceId, eventIdentifierF, sharedSource as Observable<TypedEvent<F>>);
this.addTypedEventSource(
sourceId,
eventIdentifierA,
sharedSource as Observable<TypedEvent<ToEventIdValueType<IDA>>>,
);
this.addTypedEventSource(
sourceId,
eventIdentifierB,
sharedSource as Observable<TypedEvent<ToEventIdValueType<IDB>>>,
);
this.addTypedEventSource(
sourceId,
eventIdentifierC,
sharedSource as Observable<TypedEvent<ToEventIdValueType<IDC>>>,
);
this.addTypedEventSource(
sourceId,
eventIdentifierD,
sharedSource as Observable<TypedEvent<ToEventIdValueType<IDD>>>,
);
this.addTypedEventSource(
sourceId,
eventIdentifierE,
sharedSource as Observable<TypedEvent<ToEventIdValueType<IDE>>>,
);
this.addTypedEventSource(
sourceId,
eventIdentifierF,
sharedSource as Observable<TypedEvent<ToEventIdValueType<IDF>>>,
);
if (this.currentLifecycleObjects !== null) {

@@ -837,3 +902,3 @@ this.currentLifecycleObjects.events.push(sourceId);

* and share(). So events will always be received asynchronously (expecting synchronous event dispatch would
* be a strong indicator of flawed design, because it could break MVU/reactivity).
* be a strong indicator of flawed design, because it could break reactivity).
* If this store has a parent store, events from both, parent and child will be observed (merged).

@@ -840,0 +905,0 @@ *

@@ -1,8 +0,21 @@

import { combineLatest, Observable, of } from 'rxjs';
import { combineLatest, firstValueFrom, Observable, of } from 'rxjs';
import { catchError, delay, filter, map, scan, startWith, take, timeout } from 'rxjs/operators';
/**
* This function is a testing utility.
* It takes an observable and the expected number of values to be observed.
* The returned Promise either resolves to an array with the observed values, or rejects on error.
* If the expected number of values is not observed within the configurable timeout, the Promise resolves
* with the values observed so far.
*
* @template T - type for the values to be observed
* @param {Observable} observable - the observable.
* @param {number} length - the expected number of values to be observed before resolving the result-Promise.
* @param {number} timeoutAfter - the timeout for waiting on the expected number of values. Defaults to 3000ms
* @returns {Promise}
*/
export const getSequence = async <T>(
observable: Observable<T>,
length: number,
timeoutAfter: number = 3000, // Jest can be slow sometimes...
timeoutAfter: number = 3000,
): Promise<T[]> => {

@@ -15,16 +28,27 @@ const accObservable: Observable<T[]> = observable.pipe(

const combined: Observable<[T[], boolean]> = combineLatest([accObservable, timeoutObservable]);
return combined
.pipe(
return firstValueFrom(
combined.pipe(
filter(([result, hasTimedOut]) => hasTimedOut || result.length === length),
map(([result]) => result),
take(1),
)
.toPromise() as Promise<T[]>; // Deprecated and will be removed in rxjs8
// However, we must still support rxjs 6.x as peer dependency
),
);
};
/**
* This function is a testing utility.
* It takes an observable and array of values.
* The returned Promise resolves as soon as the number of observed values equals the array-length AND the observed values equal the array-values (using expect with .toEqual).
* It rejects in all other cases, e.g. if the expected number of values was not observed within the configurable timeout.
*
* @template T - type for the values to be observed
* @param {Observable} observable - the observable.
* @param {number} sequence - the expected values.
* @param {number} timeoutAfter - the timeout for waiting on the expected values. Defaults to 3000ms
* @returns {Promise}
*/
export const expectSequence = async <T>(
observable: Observable<T>,
sequence: T[],
timeoutAfter: number = 3000, // Jest can be slow sometimes...
timeoutAfter: number = 3000,
): Promise<void> => {

@@ -36,2 +60,5 @@ return getSequence(observable, sequence.length, timeoutAfter).then(result => {

/**
* @internal
*/
export const awaitStringifyEqualState = async <T>(

@@ -54,2 +81,5 @@ observable: Observable<T>,

/**
* @internal
*/
export const awaitError = async (

@@ -73,7 +103,13 @@ observable: Observable<any>,

/**
* @internal
*/
export const awaitCompletion = async (observable: Observable<any>): Promise<void> =>
new Promise<void>((resolve, reject) => {
observable.subscribe(() => {}, reject, resolve);
observable.subscribe({ next: () => {}, error: reject, complete: resolve });
});
/**
* @internal
*/
export const withSubscription = async (

@@ -80,0 +116,0 @@ observable: Observable<any>,

@@ -0,1 +1,4 @@

/**
* @internal
*/
type ConflictKeys<T1 extends Record<string, any>, T2 extends Record<string, any>> = {

@@ -5,2 +8,5 @@ [K in keyof T1]: K extends keyof T2 ? K : never;

/**
* @internal
*/
type NoConflictKeys<T1 extends Record<string, any>, T2 extends Record<string, any>> = {

@@ -10,2 +16,5 @@ [K in keyof T1]: K extends keyof T2 ? never : K;

/**
* @internal
*/
type Conflicts<T1 extends Record<string, any>, T2 extends Record<string, any>> = {

@@ -15,2 +24,5 @@ [K in ConflictKeys<T1, T2>]: T1[K];

/**
* @internal
*/
type NoConflicts<T1 extends Record<string, any>, T2 extends Record<string, any>> = {

@@ -20,2 +32,5 @@ [K in NoConflictKeys<Omit<T1, 'conflicts1' | 'conflicts2'>, T2>]: T1[K];

/**
* @internal
*/
type MergeResult<T1 extends Record<string, any>, T2 extends Record<string, any>> = ConflictKeys<

@@ -37,7 +52,8 @@ T1,

/**
* This type represents the result of a merge of two Record<string, any> types T1 and T2, using the following rules:
* a) If there are no conflicts between T1 and T2, then Merged<T1, T2> equals T1 & T2
* b) If there's a conflict between T1 and T2, then Merged<T1, T2> equals { conflicts1: ConflictsFromT1; conflicts2: ConflictsFromT2 } & NoConflicts<T1, T2>
* This type represents the result of a merge of two Record\<string, any\> types T1 and T2, using the following rules:
* a) If there are no conflicts between T1 and T2, then Merged\<T1, T2\> equals T1 & T2
* b) If there's a conflict between T1 and T2, then Merged\<T1, T2\> equals \{ conflicts1: ConflictsFromT1; conflicts2: ConflictsFromT2 \} & NoConflicts\<T1, T2\>
*
* Here are some examples:
* ```ts
* Merged<{

@@ -68,4 +84,5 @@ * a: string;

* }
* ```
*
*
* ```ts
* Merged<{

@@ -97,4 +114,3 @@ * conflicts1: {

* }
*
* @typedef {object} Merged<T1 extends Record<string, any>, T2 extends Record<string, any>> - result of merge for T1 and T2
* ```
*/

@@ -107,10 +123,9 @@ export type Merged<T1 extends Record<string, any>, T2 extends Record<string, any>> = MergeResult<

/**
* This function merges two Record<string, any> T1 and T2, resulting in Merged<T1, T2>
* This function merges two Record\<string, any\> T1 and T2, resulting in Merged\<T1, T2\>
*
* @typedef {function} merge
* @template T1 - type for the first argument
* @template T2 - type for the second argument
* @param {T1} t1 - first argument (extending Record<string, any>).
* @param {T2} t2 - second argument (extending Record<string, any>).
* @returns {Merged<T1, T2>}
* @param {T1} t1 - first argument (extending Record\<string, any\>).
* @param {T2} t2 - second argument (extending Record\<string, any\>).
* @returns {Merged}
*/

@@ -181,6 +196,9 @@ export const merge = <T1 extends Record<string, any>, T2 extends Record<string, any>>(

/**
* Just a type alias for Record<string, any>
* Just a type alias for Record\<string, any\>
*/
export type Configuration = Record<string, any>;
/**
* @internal
*/
type NM<T1 extends Configuration, T2 extends Configuration> = T1 & T2;

@@ -190,6 +208,4 @@

* This type represents the result of a merge of two Configuration types T1 and T2, using the following rules:
* a) If either T1 or T2 is an empty object, then MergedConfiguration<T1, T2> equals T1 & T2
* b) If both, T1 and T2, are non-empty then MergedConfiguration<T1, T2> equals { c1: T1; c2: T2 }
*
* @typedef {object} MergedConfiguration<T1 extends Configuration, T2 extends Configuration> - result of merge for T1 and T2
* a) If either T1 or T2 is an empty object, then MergedConfiguration\<T1, T2\> equals T1 & T2
* b) If both, T1 and T2, are non-empty then MergedConfiguration\<T1, T2\> equals \{ c1: T1; c2: T2 \}
*/

@@ -196,0 +212,0 @@ export type MergedConfiguration<

@@ -1,3 +0,2 @@

import { combineLatest } from 'rxjs';
import { distinctUntilChanged, filter, map, startWith } from 'rxjs/operators';
import { combineLatest, distinctUntilChanged, filter, map, startWith } from 'rxjs';
import {

@@ -16,24 +15,31 @@ CombinedEffectResult,

/**
* This specifies the type for the lazy combined-behavior provided as output-signal of the ValidatedInputWithResultFactory.
* This specifies the type for the lazy combined-behavior provided as output-signal of the {@link ValidatedInputWithResultFactory}.
*
* @typedef {object} ValidatedInputWithResult<Input, ValidationResult, Result> - type for the behavior produced by ValidatedInputWithResultFactory
* @template Input - specifies the input type for both, the validation-effect and the result-effect
* @template ValidationResult - specifies the result-type of the validation-effect
* @template Result - specifies the result-type of the result-effect
* @property {Input | undefined} currentInput - current input (which might differ from the resultInput)
* @property {Input | undefined} validatedInput - the input that produced the current validationResult (or undefined, if validationResult is undefined)
* @property {ValidationResult | undefined} validationResult - the current validationResult (or undefined, if no validation-result was received yet)
* @property {boolean} validationPending - indicates whether the validation-effect is currently running.
* @property {Input | undefined} resultInput - the input that produced the current result (or undefined, if result is undefined)
* @property {Result | undefined} result - the current result (or undefined, if no result was received yet)
* @property {boolean} resultPending - indicates whether the result-effect is currently running.
*/
export type ValidatedInputWithResult<Input, ValidationResult, Result> = {
/** current input (which might differ from the resultInput) */
currentInput?: Input;
/** indicates whether the validation-effect is currently running */
validationPending: boolean;
/** the input that produced the current validationResult (or undefined, if validationResult is undefined) */
validatedInput?: Input;
/** the current validationResult (or undefined, if no validation-result was received yet) */
validationResult?: ValidationResult;
/** whether the current validationResult represents a valid state (false, if current validationResult is undefined) */
isValid: boolean;
/** indicates whether the result-effect is currently running */
resultPending: boolean;
/** the input that produced the current result (or undefined, if result is undefined) */
resultInput?: Input;
/** the current result (or undefined, if no result was received yet) */
result?: Result;

@@ -43,3 +49,3 @@ };

/**
* The analog to EffectInputSignals, just for ValidatedInputWithResultFactory.
* The analog to {@link EffectInputSignals}, just for {@link ValidatedInputWithResultFactory}.
*/

@@ -54,3 +60,3 @@ export type ValidatedInputWithResultInput<Input> = {

/**
* The analog to EffectOutputSignals, just for ValidatedInputWithResultFactory.
* The analog to {@link EffectOutputSignals}, just for {@link ValidatedInputWithResultFactory}.
*/

@@ -66,3 +72,3 @@ export type ValidatedInputWithResultOutput<Input, ValidationResult, Result> = {

/**
* The analog to EffectConfiguration, just for ValidatedInputWithResultFactory.
* The analog to {@link EffectConfiguration}, just for {@link ValidatedInputWithResultFactory}.
*/

@@ -81,3 +87,3 @@ export type ValidatedInputWithResultConfig<Input, ValidationResult, Result> = {

/**
* The analog to EffectFactoryEffects, just for ValidatedInputWithResultFactory.
* The analog to {@link EffectFactoryEffects}, just for {@link ValidatedInputWithResultFactory}.
*/

@@ -90,3 +96,3 @@ export type ValidatedInputWithResultEffects<Input, ValidationResult, Result> = {

/**
* The ValidatedInputWithResultFactory is composed of two EffectSignalsFactory, to abstract over all
* The ValidatedInputWithResultFactory is composed of two {@link EffectSignalsFactory}s, to abstract over all
* scenarios where you need to validate a certain input and run a result-effect only if the validation

@@ -174,3 +180,3 @@ * has passed successfully.

/**
* Generic function to create a specific ValidatedInputWithResultFactory.
* Generic function to create a specific {@link ValidatedInputWithResultFactory}.
*/

@@ -177,0 +183,0 @@ export const getValidatedInputWithResultSignalsFactory = <

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc