Comments (7)
Custom actor parameters are not yet implemented in Comedy, but this feature should certainly be present.
There is, however, a resource injection mechanism in Comedy. It's not yet documented, but you can see examples in test/test-system.js
("should properly inject resources defined in contexts" and the like).
If shared resource is not what you need, you can try to get away with initialization message.
from comedy.
Yes but you have the same problem when you define your context:
class MyContext {
initialize() {
this.resource = myVariable;
}
getResource() {
return this.resource;
}
}
myVariable
is unknown
from comedy.
Yes, the context with all it's resources is supposed to be self-contained.
In your case, the initialization message would work. Custom actor parameters will be implemented shortly.
from comedy.
Implemented in v0.1.0
. Here is an example test:
it('should be able to pass custom parameters to child actor', P.coroutine(function*() {
class MyActor {
initialize(selfActor) {
this.helloResponse = selfActor.getCustomParameters().helloResponse;
}
hello() {
return this.helloResponse;
}
}
// Create child actor with custom parameter.
var childActor = yield rootActor.createChild(MyActor, {
mode: 'forked',
customParameters: { helloResponse: 'Hi there!' }
});
var response = yield childActor.sendAndReceive('hello');
expect(response).to.be.equal('Hi there!');
}));
Enjoy!
from comedy.
Works perfectly THANKS.
from comedy.
It seems that if I put a function in the parameters it works for non-forked actor but that functions are filtered out of the parameters when the actor is forked.
Any idea how to pass functions as parameters for forked actors ?
from comedy.
Well, yeah, for now I've just added support for plain objects in custom parameters. Class and function passing will be done in a next step (you can create an issue for that).
from comedy.
Related Issues (20)
- Supervision support? HOT 3
- Can Resource depends on another Resource? HOT 1
- "Error: externalFunction is not defined" in forked nodes HOT 3
- Location Transparency? HOT 3
- Promise.defer is deprecated warning HOT 5
- tsc compile error HOT 1
- Dependencies inside Resources in forked modules HOT 1
- TypeError: Cannot read property 'send' of undefined HOT 2
- Actor State Names
- hot config reloads do not consider actor custom parameters HOT 7
- ActorRef passing is somewhat limited.
- Sending the message 0 produces undefined for forked and threaded actors. HOT 3
- State of an actor passed into a forked actor does not get updated.
- DEPENDENCY: Winston failing on node 14 HOT 5
- Discussion: drop configuration loading
- Suggestion: drop bluebird and leverage async/await HOT 3
- Test dependencies in package HOT 2
- Vulnerability updates: underscore and winston HOT 1
- comedy in browser HOT 2
- hey, is comedy still alive ? HOT 1
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 comedy.