File: ofarraychanges.md

package info (click to toggle)
node-rx 4.1.0%2Bdfsg1-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 8,992 kB
  • sloc: javascript: 57,049; sh: 43; makefile: 5
file content (51 lines) | stat: -rw-r--r-- 1,389 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
### `Rx.Observable.ofArrayChanges(array)`
[Ⓢ](https://github.com/Reactive-Extensions/RxJS/blob/master/src/core/linq/observable/ofarraychanges.js "View in source")

Creates an Observable sequence from changes to an array using `Array.observe`.

#### Arguments
1. `array` *(`Array`)*: The array to observe changes using `Array.observe`

#### Returns
*(`Observable`)*: An observable sequence containing changes to an array from `Array.observe`.

#### Example
```js
var arr = [1,2,3];
var source = Rx.Observable.ofArrayChanges(arr);

var subscription = source.subscribe(
  function (x) {
    console.log('Next: %s', x);
  },
  function (err) {
    console.log('Error: %s', err);
  },
  function () {
    console.log('Completed');
  });

arr.push(4);

// => Next: {type: "splice", object: Array[4], index: 3, removed: Array[0], addedCount: 1}
```

### Location

File:
- [`/src/core/linq/observable/ofarraychanges.js`](https://github.com/Reactive-Extensions/RxJS/blob/master/src/core/linq/observable/ofarraychanges.js)

Dist:
- [`rx.all.js`](https://github.com/Reactive-Extensions/RxJS/blob/master/dist/rx.all.js)

Prerequisites:
- None

NPM Packages:
- None

NuGet Packages:
- [`RxJS-Complete`](http://www.nuget.org/packages/RxJS-Complete)

Unit Tests:
- [`/tests/observable/ofarraychanges.js`](https://github.com/Reactive-Extensions/RxJS/blob/master/tests/observable/ofarraychanges.js)