Skip to content

Instantly share code, notes, and snippets.

@Chester97

Chester97/foo.ts Secret

Created June 5, 2021 15:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Chester97/0519651367ae9c4f3e6050bd5cf2fe09 to your computer and use it in GitHub Desktop.
Save Chester97/0519651367ae9c4f3e6050bd5cf2fe09 to your computer and use it in GitHub Desktop.
const vat_input: HTMLInputElement = document.querySelector(".vat_input");
const netto_input: HTMLInputElement = document.querySelector(".netto_input");
const add_inputs_button: HTMLButtonElement = document.querySelector(".add_inputs_button");
const result_value: HTMLDivElement = document.querySelector(".result_value");
const vatInputEvent$ = fromEvent(vat_input, 'change').pipe(
pluck('target', 'value'),
map((val) => val ? parseFloat(String(val)) : 0),
map((val) => isFloat(val) ? parseFloat(val.toFixed(2)) : val),
distinctUntilChanged(),
);
const nettoInputEvent$ = fromEvent(netto_input, 'change').pipe(
pluck('target', 'value'),
map((val) => val ? parseFloat(String(val)) : 0),
map((val) => isFloat(val) ? parseFloat(val.toFixed(2)) : val),
distinctUntilChanged(),
);
const foo$ = combineLatest([vatInputEvent$, nettoInputEvent$], (a,b) => {
return {a,b}
});
const addInputsValueButton$ = fromEvent(add_inputs_button, 'click').subscribe(() => WHAT NOW?); // How to get values from foo$ here?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment