-
Notifications
You must be signed in to change notification settings - Fork 0
Parser
Brod edited this page Jul 20, 2018
·
2 revisions
A Parser is similar to an Action
in redux, it's used to format data and which will be passed onto a Handler.
The jackle.parser()
method accepts a single Parser or an array or Parsers.
jackel.parser(my_parser);
// or
jackel.parser([ my_parser, my_other_parser ]);
The Parser interface and it's types are available under the Jagwah.parser
namespace.
export module Jackle {
...
export module parser {
export type input = any;
export type output = any;
export type func = (data: Jackle.parser.input) => Jackle.parser.output;
}
export interface parser {
name: string;
parser: Jackle.parser.func;
}
}
The example below expects an input
element to be passed in and it returns that element's value
.
const update_temp_parser: Jackle.parser = {
name: 'update:temp',
parser: (input: HTMLInputElement) => {
return input.value;
}
}
// register
jackle.parser(update_temp_parser);
// usage
jackle.change('update:temp', document.querySelector('input'));