deep-foundation / deep-foundation/deeplinks

`useDeepSubscription` returns empty array instead on first render with isLoading: false

Open
#97 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
13
Forks
8
PR merge metrics
No merged PRs in 30d

Description

# Not expected
I have 1 link with type BatteryLevel
```ts
const { data, loading, error } = useDeepSubscription({
type_id: {
_id: ['@deep-foundation/device', 'BatteryLevel'],
},
});

useEffect(() => {
console.log({ data, loading,error });
}, [data, loading]);
```
```
{data: Array(0), loading: true, error: undefined}
{data: Array(0), loading: false, error: undefined} // Why is this here?
{data: Array(1), loading: false, error: undefined}
```

# Expected
I have 1 link with type BatteryLevel
```ts
const { data, loading, error } = useDeepSubscription({
type_id: {
_id: ['@deep-foundation/device', 'BatteryLevel'],
},
});

useEffect(() => {
console.log({ data, loading,error });
}, [data]);
```
```
{data: Array(0), loading: true, error: undefined}
{data: Array(1), loading: false, error: undefined}
```
I have 0 links with type BatteryLevel
```ts
const { data, loading, error } = useDeepSubscription({
type_id: {
_id: ['@deep-foundation/device', 'BatteryLevel'],
},
});

useEffect(() => {
console.log({ data, loading,error });
}, [data]);
```
```
{data: Array(0), loading: true, error: undefined} // No output with loading false
```
I have 0 links with type BatteryLevel
```ts
const { data, loading, error } = useDeepSubscription({
type_id: {
_id: ['@deep-foundation/device', 'BatteryLevel'],
},
});

useEffect(() => {
console.log({ data, loading,error });
}, [data, loading]);
```
```
{data: Array(0), loading: true, error: undefined}
{data: Array(0), loading: false, error: undefined}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.