Atomico 0.19.0
Atomico 0.19.0
Improvement for error capture.
The definition of props generates a blocking error to capture by a Promise
or tryCatch
, this capture gives more information about the error, be it target
that emits the error, schema
as the structure given for the property, eg:
try {
targetComponent.myNumber = {};
} catch (e) {
console.log(e.target);
}
This with the intention of improving the focus towards the component that emits the error
Improvements for props
new support of Type Function
This, like other supported types, has a behavior only as a property, so it does not support properties such as reflect
, eg:
MyComponent.props = {
myFunction: Function
};
document.querySelector("my-component").myFunction = () => "...hi!";
Support for values as options
by declaring the prop as an object, you could define the options
property to limit the valid options, eg:
MyComponent.props = {
myString: {
type: String,
options: ["success", "error"]
}
};
Improvements for typescript
Interface for components and props
This interface improves component definition, allowing to extend the definition of props and error with autocomplete, eg:
import { h, useState, Component } from "atomico";
const MyComponent: Component = () => <host />;
MyComponent.props = {
myString: {
type: String,
options: ["success", "error"]
}
};
It can be improved through the PropSchema
interface, allowing to extend the type of declaration as a rule for the construction of the property, eg:
import { PropSchema } from "atomico";
export const CustomProp: PropSchema<number> = {
type: Number,
options: [1, 2, 3, 4],
value: 1
};
declaration for hooks
All hooks of the model atomico
, atomico/use-lazy
and atomico/hml
now have type definition, eg:
let [count, setCount] = useState(0);
type number will be a rule for count and setCount, the type can be forced using useState<CustomType>()
** More type declaration in index.d.ts**