Closed Zhuinden closed 5 years ago
Possibly want something like addForLookup
/addBundleable
.
Of course, the default automatic behavior is super nice, so I definitely wouldn't want to force the user to always add these two things separately.
I wonder how the service lifecycle callbacks would work in this scenario. Should probably still trigger them.
I also like the name rebind
, because this generally comes up if you add an object as its own class, but you also bind it as some kind of interface implementation.
It would imply that this service had already been added, so bundleable registration is not needed.
(Should I add any verifications around "rebind should be called for services already added"?)
Eh it should be just be addService(service, false)
That's actually very tacky. I guess I'll just put it off for now...
I like the name bindAlias
.
....Ugh, I should not be so trigger happy. 😞
Without serviceBinder.get()
returning alias as a service, this feature is actually very problematic!
I need to release 2.0.2 with the fixed semantics.
And then 2.0.3 without the attempt to "make sure the service is registered first, before adding an alias" because I was really screwing it up and I really needed this feature out by now. :thinking:
It was added and it is called serviceBinder.addAlias()
, or with the new extensions, serviceBinder.rebind<OtherName>(originalService)
.
Currently, every added service in every added scope is
toBundle()
'd by their service tag.Clearly if a service is registered in multiple scopes with multiple service tags, then saving its state for each scope / service tag is extremely excessive in a world where
onSaveInstanceState
has a size limit.Also,
fromBundle
thankfully now runs only ONCE (beforeonServiceRegistered
), so while it is risky to detect thattoBundle()
shouldn't be called multiple times, it would definitely make sense for the end user to say "actually this is just the same thing registered by a different name, I don't need state persistence callbacks based on this registration".