ObserveLifecycle

Registers a new lifecycle observer for the lifetime of the composition of this function, then clears it.