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

Add support to async functions in Policies #22

Open
yudikubota opened this issue Oct 19, 2020 · 3 comments · May be fixed by #23
Open

Add support to async functions in Policies #22

yudikubota opened this issue Oct 19, 2020 · 3 comments · May be fixed by #23

Comments

@yudikubota
Copy link

I have a use case where (sometimes) I need to access the DB to get some info about what a user can do. That's not possible without async functions in policies. I had to rewrite some things to make it work.

I think adding native support to async functions in Policies would be a nice new feature.

@mblarsen
Copy link
Owner

Would you be interested in making a PR for this feature?

You would need to update the return type of this function and then the implementation of the few places that it is used.

https://github.com/mblarsen/browser-acl/blob/master/types/index.d.ts#L31

For some() and every() you can use Promise.all()

@yudikubota
Copy link
Author

Hello again,

I'm interested in making a PR for this feature but I don't have much experience with TypeScript.

Also, in order to call await Promise.all(), we would need to make some() and every() async functions as well. It would break existing applications.
beforeAll() in particular, depends on the return value of the promise to return or call another function.
We can make all functions asynchronous in a new version or make brand new async functions to handle it.

Any sugestions?

@mblarsen mblarsen linked a pull request Nov 13, 2020 that will close this issue
@mblarsen
Copy link
Owner

Hi @yudikubota the linked PR implements async for all functions. However, I have to think about support for vue-browser-acl.

Do you mind doing a review of the PR. Just scan through the async parts: beforeAll, some, every.

(all tests updated and passing)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants