Skip to content

Commit 1959e86

Browse files
committed
add arg.call again and optimize code, export get
1 parent 659c30a commit 1959e86

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "usub",
33
"description": "Subscribe to any reactive sources",
4-
"version": "0.0.7",
4+
"version": "0.0.8",
55
"type": "module",
66
"source": "./src/index.js",
77
"main": "./dist/index.js",

src/index.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ const
3131
arg[Symbol.observable] || // Observable symbol
3232
arg[Symbol.asyncIterator] || // Async iterator
3333
arg.then || // Promise
34+
arg.call || // Function
3435
arg.subscribe || // Observable with subscribe method
3536
api.is(arg) // Custom observable check
3637
),
3738

3839
sub = (target, stop, unsub) => (next, error, complete) => target && (
3940
unsub = unsubr((target[Symbol.observable]?.() || target).subscribe?.((v) => next(get(v)), error, complete), complete) ||
40-
(target.call && !api.is(target) && api.effect(() => next(get(target)))) ||
41-
(api.is(target) && api.effect(() => next(get(target)))) ||
41+
((target.call || api.is(target)) && api.effect(() => next(get(target)))) ||
4242
(target.then?.(v => (!stop && next(get(v)), complete?.()), error)) ||
4343
(async v => {
4444
try {
@@ -56,4 +56,5 @@ export {
5656
is,
5757
api,
5858
sub,
59+
get
5960
}

0 commit comments

Comments
 (0)