Initialize dfinity class asynchronous callback

Possible to have an asynchronous callback when instantiating a new dfinity actor?

I want to be able to link up to a new actor from within an actor. Currently the way Dfinity seems to do this is a bit verbose.

You should be able to pass a call back to an actor class constructor, but you won’t be able to invoke it during initialization, only from with a method of the actor (so some time after initialization). There is actually a restriction in the IC spec that prevents a canister from sending messages during canister initialization. Motoko enforces this in the type system.

For a perhaps related, simple example of dynamically instantiating canisters, see here:

(Note however, that that example needs to pass additional cycles on each canister installation to actually run on the platform - we should update the code or provide full code elsewhere).

Thanks, for the tip.

There is actually a restriction in the IC spec

Do you know why this is? It would be quite useful when instantiating smart-contracts.

Also a separate unrelated question,how can one implement a new stable class? Do you have to implement the clone method?