-
Notifications
You must be signed in to change notification settings - Fork 28
Event observers in singleton are registered multiple times #157
Copy link
Copy link
Open
Milestone
Description
Consider the following situation:
@Application
class App {
@Inject Library lib;
}@Activity
class Main {
@Inject Library lib;
}@Singleton
class Library {
@Observes
void onEvent (SomeEvent event) {
// handle event
}
}In this situation event observer is registered and executed twice.
And each injection in each component registers yet another observer.
I've looked through generated code and I think the best way to solve this problem is to register observers for singletons not in component's onCreate method, but in singleton's ...$$UnscopedProvider.get method.
This would also solve the problem of observers' persistence between different activities, services etc
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels