Open kyasbal opened 7 years ago
Asynchronous attributes typically hard to operate them. We need feature to handle asynchronous attributes easily.
If an converter returned a Promise instance, Attribute#value should be resolved value. For example, material is asynchronous attribute.
Attribute#value
material
function convertMaterial(){ return new Promise((resolve,reject)=>{ // SOMETHING resolve(new Material(....)); }); }
Before this feature
NodeInterface#getAttribute("material") => Promise<Material>;
After this feature
NodeInterface#getAttribute("material") => Material;
For changing this feature, we need define several APIs.
watch API also should be fired when the attribute was resolved.
watch("material",(mat:Material)=>{ // mat should be Material instance. not Promise. });
if immediate flag is set, the watch function is fired after resolving current Promise.
immediate
isPending provides information that specified attribute is waiting for Promise or not.
Component#isPending(attributeName:string):boolean;
These method should return Promise instance that is currently waiting for.
NodeInterface#setAttribute("material",something)=>void;
NodeInterface#setAttribute("material",something)=>Promise<Material>;
Asynchronous attributes typically hard to operate them. We need feature to handle asynchronous attributes easily.
Change behaviour of fetching attribute if the attribute converter returned Promise.
If an converter returned a Promise instance,
Attribute#value
should be resolved value. For example,material
is asynchronous attribute.Before this feature
After this feature
Several API changes
For changing this feature, we need define several APIs.
watch API
watch API also should be fired when the attribute was resolved.
if
immediate
flag is set, the watch function is fired after resolving current Promise.isPending API
isPending provides information that specified attribute is waiting for Promise or not.
NodeInterface#setAttribute, Component#setAttribute
These method should return Promise instance that is currently waiting for.
Before this feature
After this feature