Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is the very first step in moving the code base away from any Meteor dependency.
The idea is to do this in parts, without breaking any code that depends on the "extracted" functions. So all extracted functions will be changed to return Promises, but to not break the current code we'll be also exporting those functions with
Promise.await
, so they'll still run "sync" in a Fiber environment.So as you can see, here is the new promisified version of
canAccessRoom
and here is thePromise.await
version being exported. So from now on, all code running within a Fiber that wants to use thecanAccessRoom
function will have to import thePromise.await
version (as you can see here)The same applies to all other rewrited functions like hasPermission.
In order to accomplish that, we had to move away from Meteor collections as well, because they are designed to run within a Fiber. So I have created a new raw.js file in
/model
directory, that exports the new "raw" (actually, MongoDB driver collections) version of a regular model. The collections methods are being rewritten as needed.The last bit included in this PR is related to Settings, the same reason as the collections, the old settings objects relies on Fibers, so I've created a simple cached get/set functions feeded by a new observer