Skip to content

Commit

Permalink
add RxRef Collection.toArray
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-smart committed Sep 22, 2023
1 parent de946d1 commit a2c19f4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/shiny-months-worry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@effect-rx/rx": patch
---

add RxRef Collection.toArray
1 change: 1 addition & 0 deletions docs/rx/RxRef.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export interface Collection<A> extends ReadonlyRef<ReadonlyArray<RxRef<A>>> {
readonly push: (item: A) => Collection<A>
readonly insertAt: (index: number, item: A) => Collection<A>
readonly remove: (ref: RxRef<A>) => Collection<A>
readonly toArray: () => Array<A>
}
```

Expand Down
5 changes: 5 additions & 0 deletions packages/rx/src/RxRef.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export interface Collection<A> extends ReadonlyRef<ReadonlyArray<RxRef<A>>> {
readonly push: (item: A) => Collection<A>
readonly insertAt: (index: number, item: A) => Collection<A>
readonly remove: (ref: RxRef<A>) => Collection<A>
readonly toArray: () => Array<A>
}

/**
Expand Down Expand Up @@ -186,4 +187,8 @@ class CollectionImpl<A> extends ReadonlyRefImpl<Array<RxRef<A>>> implements Coll
}
return this
}

toArray() {
return this.value.map((ref) => ref.value)
}
}

0 comments on commit a2c19f4

Please sign in to comment.