generated from snivilised/astrolib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(rx): add optional single (#125)
- Loading branch information
1 parent
f8a65ed
commit 0c3fa31
Showing
15 changed files
with
1,106 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package rx | ||
|
||
type factoryIterable[I any] struct { | ||
factory func(opts ...Option[I]) <-chan Item[I] | ||
} | ||
|
||
func newFactoryIterable[I any](factory func(opts ...Option[I]) <-chan Item[I]) Iterable[I] { | ||
return &factoryIterable[I]{factory: factory} | ||
} | ||
|
||
func (i *factoryIterable[I]) Observe(opts ...Option[I]) <-chan Item[I] { | ||
return i.factory(opts...) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package rx | ||
|
||
type justIterable[I any] struct { | ||
items []I | ||
opts []Option[I] | ||
} | ||
|
||
func newJustIterable[I any](items ...I) func(opts ...Option[I]) Iterable[I] { | ||
return func(opts ...Option[I]) Iterable[I] { | ||
return &justIterable[I]{ | ||
items: items, | ||
opts: opts, | ||
} | ||
} | ||
} | ||
|
||
func (i *justIterable[I]) Observe(opts ...Option[I]) <-chan Item[I] { | ||
option := parseOptions(append(i.opts, opts...)...) | ||
next := option.buildChannel() | ||
items := make([]Item[I], 0, len(i.items)) | ||
|
||
for _, item := range i.items { | ||
items = append(items, Of(item)) | ||
} | ||
|
||
go SendItems(option.buildContext(emptyContext), next, CloseChannel, items...) | ||
|
||
return next | ||
} |
Oops, something went wrong.