So I know that one of the benefits for delegates is to put code in the middle of a method or anywhere depending where the delegate method is called.
But I also read that it is beneficial to access code in higher model from lower model. If what I understood is right please let me know:
For example let's say I have Model A that references model B (which means the higher model here is A) then from what I understood I can use delegates to access methods in model A from model B.
so let's say model A has the following methods:
public void class methodA(int test)
{
info("hi");
EventHandlerResult result;
this.methodA_delegate(test,result);
info ("Bye");
}
delegate void methodA_Delegate(int _test, EventHandlerResult _Result)
{
}
Now in model B I will put the following:
class methodB()
{
[SubscribesTo(classStr(methodA), delegateStr(methodA, methodA_delegate))]
public static void methodA_methodA_Delegate(i(int _test, EventHandlerResult _Result)
{
_Result.result(10);
info(strFmt("Test is %1", _Result.result()));
}
}
Here I will get an error because I'm not referencing model A in model B ( so if I make model B references model A it will work) but they mentioned that I can access higher models from lower models so why it is not working?