vue-router-multiguard respects asynchronous guards - asynchronous

Does anyone have experience with vue-router-multiguard?
The documentation says "Guards are executed serially in the order they are supplied, respecting asynchronous ones. "
But looking at the code I don't see how it could do so.
Anyone able to help me see what I'm missing?

The author of the library responded to me on github
async behavior is achieved via the next callback parameter. The guard chain will not proceed until the current guard calls it even if it is called in an async manner. Here's the README.md example which uses setTimeout to demonstrate async behavior in guards

Related

Is a gRPC API returning "Any" a good idea?

I understand that there is no right or wrong answer here.
I see a gRPC API which returns "google.protobuf.Any". The job of the API is to take a param, which says what information needs to be fetched, and returns one of "n" things.
From an API design perspective, it is a good practice to define an API like this?
The other option would be to define a return message with "oneof" construct, which in my opinion tightly binds what the API can return.
Please let me know your thoughts.
Thanks for your time.
rpc getInformation(InfomationRequestParams) returns (google.protobuf.Any);
Returning Any from an API is common. oneof is preferred if you have a strict set of options that aren't added to often, but isn't appropriate if anyone may want to extend what is sent. The decision is similar to whether you choose to use an enum or a string in an API.
It does seem weird to not wrap the Any with a message, since generally there is type-independent information. But that's more specific to what your API actually provides and so may be fine as-is.

Where is the code of gRPC that handles deadline in the client stub?

I'm searching for when deadline starts to count down and how deadline is handled in detail in the client stub in gRPC. I think that src/cpp/client/generic_stub.cc may tell some details. In the following code block from generic_stub.cc, I think CallInternal() may include such details, but I don't find via software called Understand what CallInternal() actually does.
// begin a call to a named method
std::unique_ptr<grpc::GenericClientAsyncReaderWriter> GenericStub::Call(
grpc::ClientContext* context, const grpc::string& method,
grpc::CompletionQueue* cq, void* tag) {
return CallInternal(channel_.get(), context, method, cq, true, tag);
}
So, which part of the code in gRPC contains the detail I desire? Very looking forward to an answer! Thanks!
In grpc, deadlines aren't being "counted down", they are always absolute values that are checked against the current time.
The piece of code inside grpc that does any deadline check is located here:
https://github.com/grpc/grpc/blob/v1.21.3/src/core/ext/filters/deadline/deadline_filter.cc
In terms of code organization, the C++ upper layer you're looking at isn't doing a lot of logic, so you won't find informations like these here. The grpc core that is shared among the various wrapped languages is the place to look, usually.

Firestore Document get request promise doesn't resolve. How do I solve this problem?

Summary
I am using react-native-firebase in my project, and I am running pure react-native (No Expo). However, on putting a get request to any document on Firestore never gives a response. That is, in a try-catch block, neither does it resolve, nor does it get rejected, it keeps on going forever and ever.
(And yeah, I know about promises and I am using await/async so its not about waiting for the promise to complete, in fact, the main thing is that promises are not getting resolved/rejected)
The main issue is that this problem comes randomly, its not like it fails every time, it does it randomly. On close observation, I also observed that this happens mostly when I am constantly doing get requests, for example, I have a query which checks for the latest version in a document, now whenever I reload the app, this get query is made, and on 2-3 frequent reloads, this query never resolves.
I can do all other Firebase stuffs, like checking authentication, setting documents data, deleting, modifying editing etc. But this doesn't work out
A Bit of Background Story
This is my first project in react-native and react-native-firebase. In the past, I have been working on Ionic, and native Android (Java). I never faced this issue there. I have been searching on the internet a lot, and a few solutions that I got were mainly for the Firebase Web SDK, and not for react-native-firebase.
I found one solution, about resetting user from the Authentication console, but that never worked either. I am putting forward the link which I found (for reference, as my problem is quite similar to this, and mainly differs in the fact that I use react-native-firebase, and not the Firebase Web SDK).
https://github.com/firebase/firebase-js-sdk/issues/533
Code Samples
Get Queries (Few Code Samples which I am using)
let updateData = await firebase.firestore().doc('Updates And Errors/Updates').get();
var expensesDoc = await firebase.firestore().doc(`NewExpenses/${dateToday}`).get()
Expected Output
All Get queries should function at all times.
Actual Output
Get Queries only work when they are not called frequently. (I know its quite weird)
Have you tried using regular promise (then/catch) syntax? I have personally noticed some promise inconsistencies while using the react-native-firebase library with redux-saga's call as well (it simply didn't work, just like you mentioned). To solve my issue, I simply wrapped all the requests in functions that return a new, actual promise, which somehow worked. Still a mystery why though.
Example:
function get (query) {
return new Promise((resolve, reject) => {
query.get()
.then(data => resolve(data))
.catch(err => reject(err))
})
}
// Later use:
await get(firebase.firestore().doc('yourDoc'))
If you ever find a proper solution, please let me know, as this code obviously smells.

differences in using or not http.Client

going on Flutter documentation I found that fetching data was done, sometimes, by using http.Client and sometimes not (just http.get for example). So I was wondering the purpose of using http.Client.
These are the two sites where I found this:
https://flutter.io/cookbook/networking/fetch-data/
https://flutter.io/cookbook/networking/background-parsing/
The http package uses a default IOClient when you use the convenience http.get and http.post methods. However, sometimes you might want to use a specialized Client, for example to change the default HTTPS certificate validation. See this question.
In this circumstance, you can create any Client subclass and use it in the ways shown in your second link. It's rarely necessary, though so the syntax used in your first link is normally sufficient.

Streaming an http response within a composed action in Play! Framework 2.1

I'm creating an authentication action that wraps other actions, using the Play Zentasks sample app as a template. One of the things that this needs to be able to do, is hit a webservice in certain circumstances, in order to retrieve a user's details. I want to do this in a non-blocking fashion, but I don't want to have to pass a future back to the action that I'm wrapping.
The only way that I can think of doing this is by using Enumerator.fromStream() with an InputStream pulled from a URL object. I'm guessing this isn't the best way though, since it seems like a duplication of efforts (considering the ws object). The async ws api (and underlying asynchttpclient) returns a Future for everything however. I don't suppose anyone has tackled this issue before and could point me in another direction? Is there something that I'm missing? Also, would using a Enumerator.fromStream() as I've suggested definitely not block?
Thanks in advance,
Suche
You can use the async WS api. When it returns a future, you can call map on that, and pass the value to the action you're wrapping. Now you have a future containing the result of your wrapped action. Turn that into an AsyncResult or just wrap the whole thing in an Async{} block and it should work.

Resources