[REQ] custom element typed attribute
hanako-eo opened this issue · comments
Hana commented
Explications
- cating type attribute, auto string and autorise casting to number, bool or more (auto casting for number and boolean)
Syntax / Example
import { createReactor } from "yeap/app"
import { define } from "yeap/web"
function MyCounter ({ start = 0, ref: element }) {
const count = createReactor(start)
return (
<div>
<p>{count}</p>
<button onClick={() => count((count) =>count + 1)}>+</button>
</div>
)
}
MyCounter.attributeTypes = {
start: Number // auto cast to number
/* cast function, use .compute if is a reactiveAttributes
start(el, v){
return +v
}
*/
}
define("my-counter", MyCounter, {
reactiveAttributes: [],
shadowed: "closed"
})