Fjord wrote: ↑Wed Mar 02, 2022 2:28 pm
I'm building a system using 4 stacks and it's getting kinda messy.
Now, I bought and was reading the nice book "Livecode Advanced Application Architecture" by Ande Garzia. He mentions the publish/subscribe mechanism, and I thought it would be nice to try it. He also mentions a publish/subscribe package that's supposed to be linked [how?] with the book but it doesn't
come with the book and I couldn't find it anywhere on the web.
Today I thought of looking here and found this.
Re: Resize-aware fields?
by stam » Thu Feb 03, 2022 6:46 pm
(…)
is there some kind of publish/subscribe mechanism i can take advantage of
Maybe someone here can point me to either the code mentioned by Ande Garzia or some other code along the same line…?
Hi Fjord - Probably best to contact Andre directly.
His handle on this forum is
SoapDog - just send him an IM.
If you have no luck, IM me and i can try and dig out the files for you as i too bought that book some time ago.
Not sure what the licence for these files is so not sharing on this forum.
On a related note however - i've considered this pattern several times but haven't really put it into use. LC offers many mechanisms to overcome the same issues, and it always seems much simpler and easier to just use the built in mechanisms (which is how i very effectively solved the issue you quote me on above)
Andre's book is very good in many respects; the publish/subscribe code seems more like trying to bend LC into an MVC pattern, in a way LC isn't really designed for. However i do follow some of the advice given and more recently i'm taken to using scriptOnlyStacks for model/view/controllers as my app was becoming unwieldy. But putting the necessary handlers needed by other script files in the backscripts, they're now available to all stacks and it works just fine.
Andre's publish/subscribe stack is essentially an array where each object wanting to subscribe to a message has to register individually and then you have to broadcast messages individually as well (these are user-defined messages, not system messages like mouseUp) - in all in amounts to extra code that isn't always needed.
It works, but is not simple and I suspect will end up needing just as much coding as other methods.
I haven't really put this into practice and if you do your mileage will definitely vary - let us know how this works out for you!
Stam