Pass factory instead of the whole application.