# GroupsAPI

**Kind**: interface | **Module**: [Windows](https://docs.interop.io/desktop/reference/javascript/windows/index.md) | **Access**: `io.windows.groups`

**Source**: https://docs.interop.io/desktop/reference/javascript/windows/groupsapi/index.html

API for managing window groups.

## Properties

- **`my`** (`Group`, required)
  Returns the current group of the window.

## Methods

### close

Closes a window group.

*Since: io.Connect Desktop 9.3, @interopio/desktop 6.3.1*

```ts
(group: Group | string, options?: CloseOptions) => Promise<void>
```

**Parameters**

- **`group`** (`Group | string`, required)
  The `Group` object or the ID of the window group to be closed.
- **`options`** (`CloseOptions`, optional)
  Options for closing the group that can be used to prevent closing the group and control whether to show a confirmation dialog before closing it.

**Returns**: `Promise<void>`

### create

Creates window groups.

*Since: io.Connect Desktop 9.3, @interopio/desktop 6.3.1*

```ts
(options: CreateGroupsOptions) => Promise<Group[]>
```

**Parameters**

- **`options`** (`CreateGroupsOptions`, required)
  Options for creating window groups.

**Returns**: `Promise<Group[]>`

### findGroupByWindow

Finds a group by a provided window object or window ID.

```ts
(winId: string | IOConnectWindow, success?: (group: Group) => void, error?: (error: string) => void) => Group
```

**Parameters**

- **`winId`** (`string | IOConnectWindow`, required)
  An io.Connect Window object or a window ID by which to find a window group.
- **`success`** (`(group: Group) => void`, optional)
  Callback function for handling the successfully returned result.
- **`error`** (`(error: string) => void`, optional)
  Callback function for handling errors.

**Returns**: `Group`

### getMyGroup

Retrieves the current window group.

*Since: @interopio/desktop 6.3.1*

```ts
() => Promise<IOConnectDesktop.Windows.Group>
```

**Returns**: `Promise<IOConnectDesktop.Windows.Group>`

### hibernate

Hibernates a window group.

```ts
(groupId: string) => Promise<string>
```

**Parameters**

- **`groupId`** (`string`, required)
  ID of the window group to hibernate.

**Returns**: `Promise<string>`

### list

Lists all window groups.

```ts
(success?: (groups: Group[]) => void) => Group[]
```

**Parameters**

- **`success`** (`(groups: Group[]) => void`, optional)
  Callback function for handling the successfully returned result.

**Returns**: `Group[]`

### onGroupAdded

Notifies when a new window group is added.

```ts
(callback: (group: IOConnectDesktop.Windows.Group) => void) => UnsubscribeFunction
```

**Parameters**

- **`callback`** (`(group: IOConnectDesktop.Windows.Group) => void`, required)
  Callback function for handling the event.

**Returns**: `UnsubscribeFunction`

### onGroupRemoved

Notifies when a window group is removed.

```ts
(callback: (group: IOConnectDesktop.Windows.Group) => void) => UnsubscribeFunction
```

**Parameters**

- **`callback`** (`(group: IOConnectDesktop.Windows.Group) => void`, required)
  Callback function for handling the event.

**Returns**: `UnsubscribeFunction`

### onHibernated

Notifies when a window group is hibernated.

```ts
(callback?: (groupId: string) => void) => () => void
```

**Parameters**

- **`callback`** (`(groupId: string) => void`, optional)
  Callback function for handling the event.

**Returns**: `() => void`

### onResumed

Notifies when a window group is resumed.

```ts
(callback?: (group: IOConnectDesktop.Windows.Group) => void) => () => void
```

**Parameters**

- **`callback`** (`(group: IOConnectDesktop.Windows.Group) => void`, optional)
  Callback function for handling the event.

**Returns**: `() => void`

### resume

Resumes a previously hibernated window group.

```ts
(groupId: string, activate?: boolean) => Promise<void>
```

**Parameters**

- **`groupId`** (`string`, required)
  ID of the window group to resume.
- **`activate`** (`boolean`, optional)
  Flag indicating whether to activate the group and focus the last focused app window.

**Returns**: `Promise<void>`

### waitForGroup

Waits for a group to be loaded.

```ts
(groupId: string) => Promise<IOConnectDesktop.Windows.Group>
```

**Parameters**

- **`groupId`** (`string`, required)
  ID of the group to be awaited.

**Returns**: `Promise<IOConnectDesktop.Windows.Group>`

## Related types

- [CloseOptions](https://docs.interop.io/desktop/reference/javascript/windows/closeoptions/index.md)
- [CreateGroupsOptions](https://docs.interop.io/desktop/reference/javascript/windows/creategroupsoptions/index.md)
- [Group](https://docs.interop.io/desktop/reference/javascript/windows/group/index.md)
- [IOConnectWindow](https://docs.interop.io/desktop/reference/javascript/windows/ioconnectwindow/index.md)
- [UnsubscribeFunction](https://docs.interop.io/desktop/reference/javascript/search/unsubscribefunction/index.md)
