group() allows you to perform some operations on a group of pins instead of just one of them. Because of this, a group() can act like a pin in a lot of cases.

Whenever you call .to() and .from() methods of a pin, the result will be a group of pins containing all pins you passed to the method.


When you use .to() or .from() methods on a group, all the pins in the group will be connected to (or receive a connection from) the given pin:
  /*!*/import { source, group, map } from '@connectv/core';

let a = source();
/*!*/let g = group(map(x => 'x' + x), map(x => 'y' + x));; //--> a goes to both `map()`s in g

When you call .to() on a group passing another group to it (or multiple pins), all pins in the first group will be connected to the all pins in the second group:
  /*!*/import { source, group, map, pin } from '@connectv/core';

let a = source();
/*!*/let g1 = group(map(x => 'x' + x), map(x => 'y' + x));
/*!*/let g2 = group(map(x => 'a' + x), map(x => 'b' + x));



You can use the .subscribe() method on a group to subscribe to all of its pins:
  /*!*/import { source, group } from '@connectv/core';

let a = source();
let b = source();

/*!*/group(a, b).subscribe(console.log);

Similarly, you can call .bind() method on a group. Note that this will only affect pins that have a .bind() method (other pins in the group will remain unaffected).

Clearing up

For clearing up, you can also call .clear() method on a group, which will simply invoke the .clear() method of all of the pins in it.

Further reading

Copied to Clipboard!