- We use import/export to indicate dependencies - Webpack makes sure everything loads in the correct order - We can remove all our additional script tags in index.html
19 lines
621 B
JavaScript
19 lines
621 B
JavaScript
import { inputsAreValid } from "./utils/inputs-are-valid";
|
|
import { parseInputs } from "./utils/parse-inputs";
|
|
export const run = (alertService, componentService) => {
|
|
alertService.hideErrors();
|
|
|
|
componentService.onClick(() => {
|
|
alertService.hideErrors();
|
|
const inputs = componentService.getInputs();
|
|
const parsedInputs = parseInputs(...inputs);
|
|
if (inputsAreValid(...parsedInputs)) {
|
|
const [numA, numB] = parsedInputs;
|
|
componentService.setResult(numA + numB);
|
|
} else {
|
|
componentService.setResult("");
|
|
alertService.handleAdditionError(inputs, parsedInputs);
|
|
}
|
|
});
|
|
};
|