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.

@cycle/proxy idea for circular dependecy

See original GitHub issue

After discussion with @TylorS what about such api for proxying curcular deps?

import proxy from '@cycle/proxy'
//...
function MyComponent () {
  const {imitate, stream} = proxy()
  const componentFoo = ComponentFoo({stream, DOM})
  const componentBar = ComponentBar({HTTP, componentFoo.props$})
  imitate(componentBar.value$)

as alternative to https://github.com/cyclejs/core/issues/170

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:24 (18 by maintainers)

github_iconTop GitHub Comments

4reactions
axefrogcommented, Apr 1, 2016

Honestly, I’m not a fan of the idea because it’s turning Babel into a DSL generator rather than a tool for getting early access to general language features. By using a plugin, you make Babel into a hard dependency for a Cycle app.

2reactions
axefrogcommented, Apr 1, 2016

The plugin would be entirely optional, opt-in.

Of course, and people can do what they like with their own apps, but my point is with respect to core functionality being only available via a Babel plugin. People may want to solve the problem without being cornered into the land of Babel plugins. If there’s a generic, non-plugin solution though, then there’s no issue.

Here’s an (as-yet-untested) implementation of the hypothetical helper in my example above. Note that makeStreamProxy would need an RxJS implementation. Mine is based on the Most.js version by @TylorS.

// # component-helpers.js

import {makeStreamProxy} from 'somewhere';

function makeComponentProxy(fn, sinkKeys) {
  const [sinks, hooks] =
    sinkKeys.reduce((acc, key) =>
      ([acc[0][key], acc[1][key]] = makeStreamProxy(), acc),
      [{}, {}]);
  const connect = sources => {
    const innerSinks = fn(sources);
    for(let key of sinkKeys) {
      const [sink, hook] = [innerSinks[key], hooks[key]];
      if(sink && hook) hook(sink);
    }
  };
  return [connect, sinks];
}

export function makeSinks(makeSources, signatures) {
  const proxies = Object.keys(signatures)
    .map(key => [key, ...makeComponentProxy(signatures[key])]);
  const allSinks = proxies
    .reduce((acc, [key, _, sinks]) => (acc[key] = sinks, acc), {});
  const sources = makeSources(allSinks);
  proxies.forEach(([key, connect]) => connect(sources[key]));
  return allSinks;
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Circular Dependencies in Dependency Injection - Medium
A description of how we solved a circular dependency in our dependency injection, and some of the software principles involved.
Read more >
Circular Dependencies in Spring - Baeldung
A quick writeup on dealing with circular dependencies in Spring: how they occur and several ways to work around them.
Read more >
How to solve cyclic dependency between different modules in ...
Go to project-> java compiler-> building -> Enable project specific settings. Select build path problems and give warning as option for circular ......
Read more >
Circular Dependencies in C++ - pvigier's blog
Its goal is to draw the “include” dependencies between classes in a C++ project. In particular, it allows to detect circular dependencies ......
Read more >
How to solve circular dependency?
There may be more variants to approach your problem, but I hope you get the general idea: your core problem are classes with...
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