This repository has been archived by the owner on Feb 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 221
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix flaw with event emitters and complete checkout flow for the chequ…
…e payment method. (#2108) * Allow for priority to be set on event emitters * Add payment event emitters * add new actions/status to checkout state context * implement event emitters in payment data context * refactor checkout state context to use new actions in event emitters * refactor checkout processor to handle new event emitters * fix type-defs for registered payment methods * register observer for cheque payment method integration * add inline todo * fix sort * fix tests and add test for priority usage in event emitters * remove todo and just add explanatory comment * condense sort logic * lowercase test description * abstract emitter callback to reduce code * don’t process passed in errors if it’s undefined * improve error response expectation for payment processing event observer
- Loading branch information
Showing
21 changed files
with
530 additions
and
256 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
assets/js/base/context/cart-checkout/event-emit/emitter-callback.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import { actions } from './reducer'; | ||
|
||
export const emitterCallback = ( type, dispatcher ) => ( | ||
callback, | ||
priority | ||
) => { | ||
const action = actions.addEventCallback( type, callback, priority ); | ||
dispatcher( action ); | ||
return () => { | ||
dispatcher( actions.removeEventCallback( type, action.id ) ); | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './reducer'; | ||
export * from './emitters'; | ||
export * from './emitter-callback'; |
Oops, something went wrong.