Skip to content
This repository has been archived by the owner on Oct 1, 2024. It is now read-only.

Commit

Permalink
Adds reload methods
Browse files Browse the repository at this point in the history
  • Loading branch information
AnwerAR committed Aug 9, 2023
1 parent e621958 commit 2ccc4bf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/CheckoutAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,21 @@ export default function CheckoutAPI(options?: CheckoutConfiguration) {
},
destroy() {
// Unmount all registered drop-in-components
Object.keys(elements).forEach((sere) => {
elements[sere].unmount();
Object.keys(elements).forEach((el) => {
elements[el].unmount();
});

// Clear store data
store.options = {} as CheckoutConfiguration;
},
reload() {
if (store.options) {
Object.keys(elements).forEach((el) => {
elements[el].update(store.options);
});
} else {
throw new Error("Invalid configurations!");
}
},
};
}
3 changes: 3 additions & 0 deletions src/DropInComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,8 @@ export default function DropInComponent(name: string, options: CheckoutConfigura
update(opt: CheckoutConfiguration | undefined): void {
if (opt) updateOptions(opt);
},
reload() {
initialise();
},
};
}

0 comments on commit 2ccc4bf

Please sign in to comment.