Is there a solution to call the subscribe function when you refresh the page?
No, there isn't, the subscribe method for a certain item on the data adapter is called when such item is subscribed by a client for the first time while the unsubscribe call for the same item is called when the last client subscribed to that item closes its session (or explicitly unsubscribes from the item).
eg: admitting a just started server, if a clients subscribes to itemX then subscribe for itemX is called on the adapter, but if a second client subscribes to itemX too the subscribe method is not called again. After that, even if the first client closes its session, the unsubscribe for itemX is not called because the second client is still subscribed.
So you can't govern the subscribe/unsubscribe call through a client as other clients may interferer.
The solution to your issue would be to track the subscribed items so that when stockGenerators is filled for the first time, if an item is already subscribed, you will be able to send the updates to the server as soon as them are available, so that the server in turn will send them to the connected clients.
HTH