You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I often run into discrepancies between the declared state of a store and the actual values held by the store. Much of this stems from improper or incomplete initialization of the store. This was ok when using the JSON patch syntax in commands because that would often create missing intermediary objects. However, since I've been using state it is much more difficult. and has made the problem of incorrect store state more obvious.
The problem with mismatched state is compounded by the difficulty in actually testing if your application correctly uses state. For instance if you have two commands, one that creates an object and another that updates that object. These commands can be used one after another without issue, but if the update command is used before the create command then often a TypeError: undefined will be thrown. This interaction cannot be caught with unit tests because the store is usually mocked to adhere to the declared state (and the declared state practically never includes undefined everywhere for uninitialized stores). The only way to catch these class of errors is to e2e test all combinations of command paths allowed by the application -- a very daunting task.
Instead, if Dojo had an initialization step that enforced the initial state of the application it would eliminate these type of difficult to catch errors that are likely to slip into production. Ideally when the store is initialized it would return a Promise so a user could initialize asynchronously and while an initial state is provided a loading screen could be displayed or a value could be set in the store to indicate the application hasn't been initialized.
Having this or any form of required initialization for the store would greatly help to close the loop between the actual value and declared values of stores.
Package Version: 7.alpha.16
Code
Ideally the defined state should always match the declared state. This is the best way I've been able to make that happen.
I would like Dojo to go through an initialization step that ensures an initial state matching the defined state. I would like this initializer to return a promise so I can act on its completion.
Actual behavior:
Dojo doesn't require any initialization of the store. This is often a source of error that is extremely difficult to test.
The text was updated successfully, but these errors were encountered:
Enhancement
I often run into discrepancies between the declared state of a store and the actual values held by the store. Much of this stems from improper or incomplete initialization of the store. This was ok when using the JSON patch syntax in commands because that would often create missing intermediary objects. However, since I've been using
state
it is much more difficult. and has made the problem of incorrect store state more obvious.The problem with mismatched state is compounded by the difficulty in actually testing if your application correctly uses state. For instance if you have two commands, one that creates an object and another that updates that object. These commands can be used one after another without issue, but if the update command is used before the create command then often a TypeError: undefined will be thrown. This interaction cannot be caught with unit tests because the store is usually mocked to adhere to the declared state (and the declared state practically never includes undefined everywhere for uninitialized stores). The only way to catch these class of errors is to e2e test all combinations of command paths allowed by the application -- a very daunting task.
Instead, if Dojo had an initialization step that enforced the initial state of the application it would eliminate these type of difficult to catch errors that are likely to slip into production. Ideally when the store is initialized it would return a Promise so a user could initialize asynchronously and while an initial state is provided a loading screen could be displayed or a value could be set in the store to indicate the application hasn't been initialized.
Having this or any form of required initialization for the store would greatly help to close the loop between the actual value and declared values of stores.
Package Version: 7.alpha.16
Code
Ideally the defined state should always match the declared state. This is the best way I've been able to make that happen.
Expected behavior:
I would like Dojo to go through an initialization step that ensures an initial state matching the defined state. I would like this initializer to return a promise so I can act on its completion.
Actual behavior:
Dojo doesn't require any initialization of the store. This is often a source of error that is extremely difficult to test.
The text was updated successfully, but these errors were encountered: