Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Promise attributes? #521

Open
kyasbal opened this issue Aug 18, 2017 · 0 comments
Open

Promise attributes? #521

kyasbal opened this issue Aug 18, 2017 · 0 comments

Comments

@kyasbal
Copy link
Member

kyasbal commented Aug 18, 2017

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.

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;

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.

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.

isPending API

isPending provides information that specified attribute is waiting for Promise or not.

Component#isPending(attributeName:string):boolean;

NodeInterface#setAttribute, Component#setAttribute

These method should return Promise instance that is currently waiting for.

Before this feature

NodeInterface#setAttribute("material",something)=>void;

After this feature

NodeInterface#setAttribute("material",something)=>Promise<Material>;
@moajo moajo mentioned this issue Sep 15, 2017
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant