circular-dependency

Injecting $http into angular factory($exceptionHandler) results in a Circular dependency

我怕爱的太早我们不能终老 提交于 2019-11-28 11:56:34
When I try inject $http into an overridden factory I get the error: Uncaught Error: [$injector:cdep] Circular dependency found: $http <- $exceptionHandler <- $rootScope AngularModule.factory('$exceptionHandler', function ($http) { any ideas how to resolve? if I inject using [], $http is undefined edit_ _ __ _ __ _ __ _ __ _ __ _ _ as per an answer below I tried: MyModule.config(function($provide, $http) { $provide.decorator("$exceptionHandler", function($delegate) { return function(exception, cause) {.. but I still get the circular error: Uncaught Error: [$injector:cdep] Circular dependency

How to avoid circular Trigger dependencies in MySQL

爱⌒轻易说出口 提交于 2019-11-28 08:49:36
I have a little probleme using Triggers in MySQL. Suppose we have 2 tables: TableA TableB And 2 Triggers: TriggerA: fires when deleting on TableA and updates TableB TriggerB: fires when deleting on TableB and deletes in TableA The problem is that when I delete some rows in TableB, TriggerB fires and deletes some elements in TableA, then TriggerA fires and tries to update TableB. It fails because TriggerA tries to update some rows in TableB that are being deleted. How can I avoid this circular dependencies? None of those two Triggers are useless, so I don't know what am I supposed to do to

Circular Dependency in Two Projects in C#

送分小仙女□ 提交于 2019-11-28 07:09:13
问题 I have two projects in a solution named ProjectA (ConsoleApplication) and ProjectB (ClassLibrary). ProjectA has a reference to ProjectB. Generally speaking, ProjectA calls a method in ProjectB to do some stuff and return the results to ProjectA. Sometimes however, I need ProjectB to send some "additional" information to ProjectA (more specifically to call the Console.WriteLine() method in ProjectA). To achieve this, I need to refer ProjectA in ProjectB, but when I try to do that, I get the

C++, two classes with mutual needs

为君一笑 提交于 2019-11-28 06:33:32
I have converted a scientific simulation platform from Java into C++. I have tried to keep the design as much as possible the same as previous implementation. In java because of the late binding, circular dependencies are resolved at the run time. However, circular dependencies have created a hell of a mess in C++. Is there an automated tool which analyses and lists the circular includes and references? (Visual Studio 2010 only issues a huge list of nonsense errors). I have tried to use forward references wherever possible. However in some occasions both classes need functionality of the other

Are circular references acceptable in database?

独自空忆成欢 提交于 2019-11-28 06:20:00
When are circular references acceptable in database? Theoretical and practical, any help is appreciated. Records which point to other records are useful in a database. Sometimes these records form a cycle. This might still be useful. The only real annoyance in practice is avoiding violating the constraints. For example, if you have a user and transaction table, the user might have a pointer to his last transaction. You need to insert the transaction first, then update the last_transaction_id to the correct value. While both these records exist you can't erase them, because the user.last

C++ Circular Dependency in Header Files

好久不见. 提交于 2019-11-28 02:20:05
Is it possible to avoid circular dependency in the following header files without turning data member b1 in class A to a pointer/reference, and without relaxing the inline function requirement in class B ? A.h: #ifndef A_H #define A_H #include <B.h> // Required, as data member b1 is not a pointer/reference class A { public: B b1; // I want to keep this as as it is. int m_a; }; #endif B.h: #ifndef B_H #define B_H #include <A.h> // Required, as f() calls a member function of class A class B { public: int f(A &a){return a.m_a;} // I want this to be an inline function. }; #endif ...and let's say

Complex circular dependency

我只是一个虾纸丫 提交于 2019-11-28 00:51:56
问题 what is the the best practice of solving circular dependency in C++ ? I could use the forward declaration, but then I get the pointer to incomplete class type is not allowed error. Does that mean that two classes that uses each others pointer cannot be dependent? Also, I thought about forward declaring each class and then including every header of the solution in the main.cpp , so it's all in one place. Would you recommend it? A snippet from the whole project is below, so you can refer to it

C++ circular include

六眼飞鱼酱① 提交于 2019-11-28 00:19:27
I can't solve this circular dependency problem; always getting this error: "invalid use of incomplete type struct GemsGame" I don't know why the compiler doesn't know the declaration of GemsGame even if I included gemsgame.h Both classes depend on each other (GemsGame store a vector of GemElements, and GemElements need to access this same vector) Here is partial code of GEMELEMENT.H: #ifndef GEMELEMENT_H_INCLUDED #define GEMELEMENT_H_INCLUDED #include "GemsGame.h" class GemsGame; class GemElement { private: GemsGame* _gemsGame; public: GemElement{ _gemsGame = application.getCurrentGame();

Circular Dependencies in Ruby

旧巷老猫 提交于 2019-11-28 00:10:09
问题 Let's say we have two classes, Foo and Foo Sub, each in a different file, foo.rb and foo_sub.rb respectively. foo.rb: require "foo_sub" class Foo def foo FooSub.SOME_CONSTANT end end foo_sub.rb: require "foo" class FooSub < Foo SOME_CONSTANT = 1 end This isn't going to work due to the circular dependency - we can't define either class without the other. There are various solutions that I've seen. Two of them I want to avoid - namely, putting them in the same file and removing the circular

How does compiling circular dependencies work?

可紊 提交于 2019-11-27 23:35:45
I've made the example in Java but I think (not tested) that it works in other (all?) languages. You have 2 files. First, M.java : public class MType { XType x; MType() {x = null;} } Second, another file (in the same directory), XType.java : public class XType { MType m; public XType(MType m) {this.m = m;} } Ok it's bad programming, but if you run javac XType it compiles: compiles even MType because XType needs it. But ... MType needs XType ... how does that work? How does the compiler know what is happening? I would like to know how the compiler (javac or any other compilers you know) manages