Should Window restore/maxmize/minmize/close use in Promise?

Here is my Window Service, should I wrap them into a Promise?

export const WindowsService = {
  restore: (windowId: string) => {
    overwolf.windows.restore(windowId);
  },
  maximize: (windowId: string) => {
    overwolf.windows.maximize(windowId);
  },
  minimize: (windowId: string) => {
    overwolf.windows.minimize(windowId);
  },
  close: (windowId: string) => {
    overwolf.windows.close(windowId);
  },
};

Thanks!

Hi!
Generally speaking, as is the case for previous questions as well - it does depend a little on your own preference, as there is rarely any one objectively correct way to do it.

However, wrapping it into promises does allow you to “respond” to the results of these methods. Do note however that most methods in the overwolf api are asynchronous, and will return their result in a callback that you pass as a parameter (which you can then also get the success/failure of the method from, if you were to “promisify” this).

For reference, while likely slightly outdated in some areas, I recommend that you take a look at common services in the community gists repo. And, if you haven’t already, do check out the developers discord. While we can always gladly help from the perspective of “the company behind the overwolf platform”, i believe it will also be useful to take into consideration the perspectives of how other app developers approach these questions of best practices while you learn.

Hope this helps!

1 Like

I think I’m doing the right way to build my service for my app.
The GitHub repo helps me a lot.

I’ll try to check out your dev discord.
Thanks for helping me figure it out my problems.

1 Like