Since this thread has sprung back to life…
Yes, it is annoying to need both a command and a subscription to do this. More annoying for the pedantically inclined is that the specification says nothing about the order in which messages will be delivered. What if the window is in the midst of resizing when the app is initializing. Is there a chance that the command result will arrive in some sequence with the subscription results that results in the wrong final value being delivered? Reportedly no, but the documentation is silent.
As for why one needs both, the issue is that issuing a command is a concrete event at the end of an update cycle and as such can trigger immediate activity. Subscriptions are just a measure of interest in a particular event and once functions to translate the underlying data become involved cannot be readily compared to one another to tell whether the subscription being returned now is a new subscription or is simply the current instance of an existing subscription. For example, if one were to write (this is contrived):
subscriptions model =
Window.resizes (WindowResized model.resizeCount)
then each time the runtime calls subscriptions it will build a new tagger function which will make the subscription look different from the previous one. In fact, it will be different whenever resizeCount changes. So, should it then deliver a result or not? Now, as I said, this is contrived in that one should probably wait for the update code to look at the model properties but the point is that it becomes impossible in practice to tell when two subscriptions are the same which is a pre-requisite to being able to fire an event when a subscription is created.
This is actually an interesting problem, not for window sizing where the command plus subscriptions is a bit awkward but relatively straightforward, but for what one would do if one wanted a way to cancel tasks. The HTTP progress module demonstrates that subscriptions can be used to provide cancelation for HTTP requests and as such could provide a pattern for canceling tasks or at least task chain execution on loss of interest. But note that it requires clients to supply unique identifiers for the subscriptions to address the issues above and these unique identifiers are themselves potentially awkward to generate unless one has natural identifiers or a readily accessible centralized source for such identifiers. The subscription handling code also has to decide what to do in the event that the other parameters to the subscription change without the identifier changing. What one almost wants is a command to create a subscription since the command execution essentially provides identity to the subscription.
Mark