I am trying to instantiate an canister from its id:
actor {
public func main(canisterId: Text) : async Nat {
let canister2 = actor(canisterId): **actor { getValue: () -> async Nat };**
return await canister2.getValue();
};
};
However, in my case I have defined the actor using an actor class, so am not sure how to declare the type signature. Anyway to get the type signature of the actor from the actor class?
If would be great to be able to have a language level feature allowing me to reference the async future type of an actor API, or to provide a default value for it while I’m waiting
For example, let’s say the actor API looks like this:
actor {
public func callMe() : Text { "hello" };
};
Then in my code I’d like to reference the type of it’s future and provide a default.
import "SomeActor";
...
func referenceActorFutureType() : async () {
// This is not possible, but having some way to do this would be great
var someActorCallMeFuture : SomeActor<callMe> = async "default";
}
This comes into play when I want to make 4-5 different calls at the same time, but I want those calls to be conditional, such that I could send out anywhere from 0 to 5 calls at a time depending on various conditions.
Most of the time I’ll only need to make 1 asynchronous call, so for various reasons I don’t want to make unnecessary calls to other actors. I’d like to be able to make these calls at the same time without I also need to be able to assign each of these conditional futures, such that I am then later on able to await and collect their responses.
@claudio are there any tricks that could help me out here?