Comments (5)
Happy New Year! 🎉
That would be very convenient to have, I like it!
What would be the use case to silently ignore rejections though? I imagine, at least in the scenarios I've used it, that it would be problematic if some variables failed to load (API keys, etc).
from cloud-functions-runtime-config.
Laziness :-(
It's unclear to me how to reconcile an array of Promises that contain resolves and rejects.
By ignoring rejects, the code is simpler... In my code currently, I have:
const getVariables = (runtimeConfig, config, variables) =>
Promise
.all(variables
.map(variable =>
runtimeConfig.getVariable(config, variable);
)
.map(p =>
p.catch(() => undefined)
)
);
from cloud-functions-runtime-config.
Haha fair enough 😄
I like the idea of keeping it simple but as a library maybe we should leave the error handling to the user.
A user could handle it with a catch
that is applied to getVariables
. Using the mechanics of Promise.all
; If all variables are loaded then
is called with an array of the values. If not catch
is called with the first rejection.
The API could look something like this:
runtimeConfig.getVariables('lunch-plans', ['monday', 'tuesday'])
.then(values => {
// this is executed if all values are loaded successfully
// values: ['valueOfMonday', 'valueOfTuesday']
})
.catch(reason => {
// this is called for the first variable that rejects
});
This does not handle the case where, after some variable rejects, we still want to continue with the other variables but that might be out of scope here unless we can find a general way of dealing with that.
from cloud-functions-runtime-config.
Commit 3fc574b adds a method called getVariables
as discussed above.
The interface is documented in README and it works as described above by wrappinggetVariable
inside a call to Promise.all
.
from cloud-functions-runtime-config.
Ah, you're good. Thank you!
from cloud-functions-runtime-config.
Related Issues (9)
- Consider global scope to 'cache' deployment (!) config HOT 3
- basic example needs update HOT 2
- get entire config at once? HOT 1
- npm install fails
- Update takes long time HOT 2
- "A Not Found error" HOT 9
- Default credentials in Cloud Functions throws Not Found HOT 2
- Add GCLOUD_PROJECT to README.md and throw error if missing HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cloud-functions-runtime-config.