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
Is your feature request related to a problem? Please describe.
In OrderProcessOptions we allow the developer to define hooks to control/interact with state transitions of the Order state machine. However, there is no opportunity to inject services or other providers, which limits the usefulness of this feature.
In #303 we created a pattern to enable injection in to most other configurable processes but failed to consider this one.
Describe the solution you'd like
There are 2 ways I can think to solve this:
Add a 4th injector argument to each callback. This would be relatively simple to implement and would not break any existing code.
Re-work the way these hooks are defined so that we have a new OrderProcessStrategy interface which implements InjectableStrategy. This interface would have optional methods for each of the existing hooks, and also allow injection (+ setup/teardown).
I am tending towards option 2 because:
It is consistent with the conventions used by Vendure
It would make it easier to compose multiple state transition hooks since we would accept an array of OrderProcessStrategy objects and execute each hook in turn in the order that they are defined.
We could do this in a non-breaking way by keeping the existing options but marking the callback methods as deprecated and eventually removing them in some future version.
The text was updated successfully, but these errors were encountered:
This commit enables composition of multiple new custom order process states, and also makes it possible to inject providers into the transition hooks. Relates to #401
BREAKING CHANGE: The way custom Order states are defined has changed. The `VendureConfig.orderOptions.process` property now accepts an **array** of objects implementing the `CustomerOrderProcess` interface. This interface is more-or-less the same as the old `OrderProcessOptions` object, but the use of an array now allows better composition, and since `CustomerOrderProcess` inherits from `InjectableStrategy`, this means providers can now be injected and used in the custom order process logic.
Is your feature request related to a problem? Please describe.
In OrderProcessOptions we allow the developer to define hooks to control/interact with state transitions of the Order state machine. However, there is no opportunity to inject services or other providers, which limits the usefulness of this feature.
In #303 we created a pattern to enable injection in to most other configurable processes but failed to consider this one.
Describe the solution you'd like
There are 2 ways I can think to solve this:
injector
argument to each callback. This would be relatively simple to implement and would not break any existing code.OrderProcessStrategy
interface which implements InjectableStrategy. This interface would have optional methods for each of the existing hooks, and also allow injection (+ setup/teardown).I am tending towards option 2 because:
OrderProcessStrategy
objects and execute each hook in turn in the order that they are defined.We could do this in a non-breaking way by keeping the existing options but marking the callback methods as deprecated and eventually removing them in some future version.
The text was updated successfully, but these errors were encountered: