Comments (4)
Maybe we should register event handlers after the app is booted @freekmurze?
from laravel-event-projector.
I'd accept a PR that moved the registration to the boot
method.
from laravel-event-projector.
@sebastiandedeyne I've just tried moving this code
$this->app->singleton(Projectionist::class, function () {
$config = config('event-projector');
$projectionist = new Projectionist($config);
$projectionist
->addProjectors($config['projectors'] ?? [])
->addReactors($config['reactors'] ?? []);
return $projectionist;
});
from the register to the boot method, but theres no change in the functionality. I assume by the time we're at the first line of a test method the app has finished registered and booted even if the test is blank.
I can't think of an obvious way to hook into the app lifecycle to swap Fakes in during tests unless I'm missing something obvious. If there is something please point me in the right direction and ill take another look.
As a work around for now I'm doing the following in my tests:
- Swapping the implementation for a fake
- Fetching the Projectionist from the app container
- Re-adding the reactor and overwriting its key held within the EventHandlerCollection.
$this->app->singleton(ClaimsManagementNotifier::class, function () use ($fakeRequests) {
$mock = new MockHandler($fakeRequests);
$handler = HandlerStack::create($mock);
$client = new \GuzzleHttp\Client(['handler' => $handler]);
return new ClaimsManagementNotifier($client);
});
/** @var Projectionist $projectionist */
$projectionist = $this->app->make(Projectionist::class);
$projectionist->addReactor(AppClaimReactor::class);
from laravel-event-projector.
Dear contributor,
because this issue seems to be inactive for quite some time now, I've automatically closed it. If you feel this issue deserves some attention from my human colleagues feel free to reopen it.
from laravel-event-projector.
Related Issues (20)
- Reduce configuration with magic HOT 1
- Create new storable event by artisan command doesn't run HOT 4
- General questions about projector and the app state in event sourcing system HOT 1
- Event Streams in V2 HOT 1
- Upgrading an app that was using event streams? HOT 1
- replay command does not support --force flag HOT 2
- Question? any way to use aggregators to check whether the balance has been tampered with automatically before adding or subtracting money or the balance? HOT 1
- Replay events when AggregateRoot::$storedEventModel used HOT 1
- [Feature Request] Optimistic concurrency control HOT 1
- get the uuid in reactor HOT 3
- Docs link in README throws 502 error HOT 1
- [Question]: how does this package handle failed jobs when using async queue? HOT 2
- Projector priority when replaying HOT 2
- Allow aliases for stored event classes instead of persisting FQCN to DB HOT 2
- Support for ephemeral events HOT 4
- artisan make:projector command not working after upgrade from v1 -> v2 HOT 2
- Cannot add metada after upgrading to v3 HOT 11
- Replay events with no-interaction flag
- Update Doc V3 installation 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 laravel-event-projector.