question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is @react-rxjs/core@0.6.0-1 a significant breaking change from 0.5.0?

See original GitHub issue

Upgrading to @react-rxjs/core@0.6.0-1 I can’t get the most basic PoC to work.

import React from "react";
import { bind, shareLatest } from "@react-rxjs/core";
import { timer } from "rxjs";
import { startWith } from 'rxjs/operators';

const [useTimer] = bind(() => timer(0, 1000).pipe(startWith(0), shareLatest()));

export default function App() {
  const timer = useTimer();
  return <div className="App">{timer}</div>;
}
Error
Missing subscription

Code

If this is due to breaking changes, a suggestion would be to expand this exception message to give more detail. Plus, to add a demo package with a few working examples to provide end users with a sanity check.

If it is a regression, perhaps there can be some integration tests added.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
volivacommented, Jan 7, 2021

Hey @ilikejames - glad that you’re finding a solution.

A quick note however, just to clarify:

const [useTimer, timer$] = bind(
  timer(0, 1000).pipe(shareLatest())
, 0);

const [useTimerSum, timerSum$] = bind(
  timer$.pipe(scan((a,b) => a+b))
);

In this example, useTimer can be used without needing a <Subscribe /> boundary, but useTimerSum does, even if theoretically it wouldn’t dispatch suspense, so it will throw “Missing subscription” if used straight away.

This is because bind can’t really know if a stream is doing something that would become asynchronous. To avoid this (without using <Subscribe />), useTimerSum also would need a defaultValue.

Edit: Also, the shareLatest() in this example is redundant, you shouldn’t need it.

1reaction
ilikejamescommented, Jan 7, 2021

No need to apologise, though perhaps in future 0.6.0 could have been released as a prerelease version before the docs were updated 😉

I follow your last part and see that…

const [useTimer, timer$] = bind(
  timer(0, 1000).pipe(shareLatest())
, 0);

…works.

And after discussion with @voliva, using a default value in this way bypasses Suspense completely. So this is an option for the majority of our streams, and then we only need to use <Subscribe/> on the few stream that should trigger suspenseful behaviour in the ui.

Ok. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Breaking changes in .NET 7 - Microsoft Learn
NET 7, the breaking changes listed here might affect you. Changes are grouped by technology area, such as ASP.NET Core or Windows Forms....
Read more >
GitLab.com is moving to 15.0 with a few breaking changes
Some of these removals are breaking changes, because this release is a major version release. We try to minimize such breaking changes but ......
Read more >
bookshelf/CHANGELOG.md at master - GitHub
Major Breaking Changes · Global state is no longer stored in the library, an instance is returned from Bookshelf. · Lowercasing of bookshelf....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found