However, now that I am using rust I am completely poisoned with my need for a good compiler. I’m setting up a source stream with this tidbit:
const changeWeight$ = sources.DOM.select('.weight') .events('input') .map(ev => parseInt((<HTMLInputElement>ev.target).value));
basically this selects the ‘input’ events of the ‘.weight’ html element and converts the events into integer values.
There are several problems here:
- the event type is not known at compile time and I have to manually cast it as
HTMLInputElement– if I cast it incorrectly it fails extremely silently
- the event.value is a string, and to convert it I use parseInt. However, parseInt returns a NaN if it can’t parse (for an int!). NaN is one of the most silent and difficult to check for values that exist (you must use isNaN function).
It occurs to me that Cycle.js is so simple, so rustic in the way it is almost zero abstraction, that implementing it in emscripten+rust would be the perfect target for the first ever rust web frontend framework. Cycle.rs.