You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@royale.apache.org by GAbe Barbosa <gb...@gmail.com> on 2021/11/24 23:29:11 UTC

How to launch mx:Application from another mx:Application at runtime

Hi royale folks,

I've tried using mx:Modules with no success. I'm trying to come up with an
alternative solution and need help.

How would you launch/load an application from the currently running
application at runtime. Ensuring I don't get any duplicate deps is a whole
other problem, so don't worry about that for now.

Will be grateful for any ideas, suggestions. Thank you!

Re: How to launch mx:Application from another mx:Application at runtime

Posted by Harbs <ha...@gmail.com>.
More food for thought:

I love comparing this app with:

https://opensource.adobe.com/spectrum-css/ <https://opensource.adobe.com/spectrum-css/>

and 

https://react-spectrum.adobe.com/react-spectrum/index.html <https://react-spectrum.adobe.com/react-spectrum/index.html>

because if you compare the performance of the Royale implementation with the React one, you’ll see that Royale absolutely destroys React. (Use your browser profiling tools to see.) And that’s despite the fact that the React one is built with modules and the Royale one isn’t. And the engineer at Adobe who designed the React components is one of the smartest guys I know...

HTH,
Harbs

> On Dec 3, 2021, at 11:05 AM, Harbs <ha...@gmail.com> wrote:
> 
> I don’t know how complex your views are but I recommend you look at this:
> https://github.com/unhurdle/spectrum-royale <https://github.com/unhurdle/spectrum-royale>
> 
> We have a demo here with 80 routed components
> https://unhurdle.github.io/spectrum-royale/ <https://unhurdle.github.io/spectrum-royale/>

Re: How to launch mx:Application from another mx:Application at runtime

Posted by Harbs <ha...@gmail.com>.
If you do run into this, there should be work-arounds. And if not, that would be a bug that we’d like to fix.

> On Dec 3, 2021, at 11:05 AM, Harbs <ha...@gmail.com> wrote:
> 
>  It’s possible that you might run into conflicts between the CSS and CSS application of beads. That’s something to keep your eye out for.
> 


Re: How to launch mx:Application from another mx:Application at runtime

Posted by Harbs <ha...@gmail.com>.
> It might be
> the solution to have a monolith application, although my boss seems against
> this idea.

I REALLY recommend doing some profiling. Your boss is probably basing their opinion on experience with Flash. Modules were pretty important there for performance. For other JS frameworks modules are also important because they are just so slow and big.

Royale is so small and fast that modules will likely not gain you anything and might in fact hurt.

I don’t know how complex your views are but I recommend you look at this:
https://github.com/unhurdle/spectrum-royale <https://github.com/unhurdle/spectrum-royale>

We have a demo here with 80 routed components
https://unhurdle.github.io/spectrum-royale/ <https://unhurdle.github.io/spectrum-royale/>

That’s wired up with a router here:
https://github.com/unhurdle/spectrum-royale/blob/master/SpectrumBrowser/src/view/BrowserRouter.mxml <https://github.com/unhurdle/spectrum-royale/blob/master/SpectrumBrowser/src/view/BrowserRouter.mxml>

All the code is a monolith and it’s all loaded at startup time. It loads and switches views pretty instantly.

There’s also Tour de Jewel. https://royale.apache.org/tourdejewel/

> Can jewel components and mx components work together? Is a jewel
> module completely different from an mx:Module?

The underlying structure of all Royale components are based on Basic. So they are all compatible to a certain degree. You can definitely mix and match components from different sets. I’ve done so in the past. It’s possible that you might run into conflicts between the CSS and CSS application of beads. That’s something to keep your eye out for.


HTH,
Harbs

> On Dec 3, 2021, at 3:25 AM, GAbe Barbosa <gb...@gmail.com> wrote:
> 
> Ahh i see. The application I'm porting had a hub application where they
> loaded at runtime .swf applications on user demand. They have about 150 of
> these "views". ModuleLoader isn't fully baked out and I still have to
> instantiate via window["module"["path"] which is a workaround. It might be
> the solution to have a monolith application, although my boss seems against
> this idea. Can jewel components and mx components work together? Is a jewel
> module completely different from an mx:Module?
> 
> On Thu, Dec 2, 2021 at 2:17 PM Harbs <ha...@gmail.com> wrote:
> 
>> There’s an <html:Iframe> component. You should use that. It sounds like
>> you are trying to add an actual html element directly in MXML. That’s not
>> going to work very well.
>> 
>>> Not sure what you mean by cross-op, but would need the apps to share many
>>> models or singletons.
>> 
>> Sharing models and singletons is not going to work in an iframe. You can
>> only share data by sending messages that can be sent as strings.
>> 
>> If you need to share models and singletons, you’ll need modules. Have you
>> looked at the ModuleExample app in the example folder?
>> 
>> That said: Why do you need modules at all? In Flash I used modules to
>> reduce the size of my main application. In Royale I have not found it to be
>> an issue.
>> 
>> Harbs
>> 
>>> On Dec 2, 2021, at 8:57 PM, GAbe Barbosa <gb...@gmail.com> wrote:
>>> 
>>> Thanks for responding Harbs!
>>> 
>>> Could you give me an example of this please. The only way I've been able
>> to
>>> load the other mx:Application is modifying the index.html and adding an
>>> <iframe src='indexOfAnotherApplication.html' > then instantiating the
>>> object via:
>>>   var obj :Object = window.frames["0"]["application"]["path"];
>>>   obj = new obj();
>>> 
>>> but then fails on adding to the screen via:
>>>   addChild(obj as IUIComponent)
>>> 
>>> Not sure what you mean by cross-op, but would need the apps to share many
>>> models or singletons.
>>> 
>>> On Thu, Nov 25, 2021 at 2:48 AM Harbs <ha...@gmail.com> wrote:
>>> 
>>>> How much cross-op do you need?
>>>> 
>>>> I’d probably load it in an iframe you can use either <html:Iframe> or
>>>> <js:WebBrowser>
>>>> 
>>>> If you need limited communication, you can use postMessage to
>> communicate
>>>> between the two apps.
>>>> 
>>>> https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage
>>>> 
>>>>> On Nov 25, 2021, at 1:29 AM, GAbe Barbosa <gb...@gmail.com>
>> wrote:
>>>>> 
>>>>> Hi royale folks,
>>>>> 
>>>>> I've tried using mx:Modules with no success. I'm trying to come up with
>>>> an
>>>>> alternative solution and need help.
>>>>> 
>>>>> How would you launch/load an application from the currently running
>>>>> application at runtime. Ensuring I don't get any duplicate deps is a
>>>> whole
>>>>> other problem, so don't worry about that for now.
>>>>> 
>>>>> Will be grateful for any ideas, suggestions. Thank you!
>>>> 
>>>> 
>> 
>> 


Re: How to launch mx:Application from another mx:Application at runtime

Posted by GAbe Barbosa <gb...@gmail.com>.
Ahh i see. The application I'm porting had a hub application where they
loaded at runtime .swf applications on user demand. They have about 150 of
these "views". ModuleLoader isn't fully baked out and I still have to
instantiate via window["module"["path"] which is a workaround. It might be
the solution to have a monolith application, although my boss seems against
this idea. Can jewel components and mx components work together? Is a jewel
module completely different from an mx:Module?

On Thu, Dec 2, 2021 at 2:17 PM Harbs <ha...@gmail.com> wrote:

> There’s an <html:Iframe> component. You should use that. It sounds like
> you are trying to add an actual html element directly in MXML. That’s not
> going to work very well.
>
> > Not sure what you mean by cross-op, but would need the apps to share many
> > models or singletons.
>
> Sharing models and singletons is not going to work in an iframe. You can
> only share data by sending messages that can be sent as strings.
>
> If you need to share models and singletons, you’ll need modules. Have you
> looked at the ModuleExample app in the example folder?
>
> That said: Why do you need modules at all? In Flash I used modules to
> reduce the size of my main application. In Royale I have not found it to be
> an issue.
>
> Harbs
>
> > On Dec 2, 2021, at 8:57 PM, GAbe Barbosa <gb...@gmail.com> wrote:
> >
> > Thanks for responding Harbs!
> >
> > Could you give me an example of this please. The only way I've been able
> to
> > load the other mx:Application is modifying the index.html and adding an
> > <iframe src='indexOfAnotherApplication.html' > then instantiating the
> > object via:
> >    var obj :Object = window.frames["0"]["application"]["path"];
> >    obj = new obj();
> >
> > but then fails on adding to the screen via:
> >    addChild(obj as IUIComponent)
> >
> > Not sure what you mean by cross-op, but would need the apps to share many
> > models or singletons.
> >
> > On Thu, Nov 25, 2021 at 2:48 AM Harbs <ha...@gmail.com> wrote:
> >
> >> How much cross-op do you need?
> >>
> >> I’d probably load it in an iframe you can use either <html:Iframe> or
> >> <js:WebBrowser>
> >>
> >> If you need limited communication, you can use postMessage to
> communicate
> >> between the two apps.
> >>
> >> https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage
> >>
> >>> On Nov 25, 2021, at 1:29 AM, GAbe Barbosa <gb...@gmail.com>
> wrote:
> >>>
> >>> Hi royale folks,
> >>>
> >>> I've tried using mx:Modules with no success. I'm trying to come up with
> >> an
> >>> alternative solution and need help.
> >>>
> >>> How would you launch/load an application from the currently running
> >>> application at runtime. Ensuring I don't get any duplicate deps is a
> >> whole
> >>> other problem, so don't worry about that for now.
> >>>
> >>> Will be grateful for any ideas, suggestions. Thank you!
> >>
> >>
>
>

Re: How to launch mx:Application from another mx:Application at runtime

Posted by Harbs <ha...@gmail.com>.
There’s an <html:Iframe> component. You should use that. It sounds like you are trying to add an actual html element directly in MXML. That’s not going to work very well.

> Not sure what you mean by cross-op, but would need the apps to share many
> models or singletons.

Sharing models and singletons is not going to work in an iframe. You can only share data by sending messages that can be sent as strings.

If you need to share models and singletons, you’ll need modules. Have you looked at the ModuleExample app in the example folder?

That said: Why do you need modules at all? In Flash I used modules to reduce the size of my main application. In Royale I have not found it to be an issue.

Harbs

> On Dec 2, 2021, at 8:57 PM, GAbe Barbosa <gb...@gmail.com> wrote:
> 
> Thanks for responding Harbs!
> 
> Could you give me an example of this please. The only way I've been able to
> load the other mx:Application is modifying the index.html and adding an
> <iframe src='indexOfAnotherApplication.html' > then instantiating the
> object via:
>    var obj :Object = window.frames["0"]["application"]["path"];
>    obj = new obj();
> 
> but then fails on adding to the screen via:
>    addChild(obj as IUIComponent)
> 
> Not sure what you mean by cross-op, but would need the apps to share many
> models or singletons.
> 
> On Thu, Nov 25, 2021 at 2:48 AM Harbs <ha...@gmail.com> wrote:
> 
>> How much cross-op do you need?
>> 
>> I’d probably load it in an iframe you can use either <html:Iframe> or
>> <js:WebBrowser>
>> 
>> If you need limited communication, you can use postMessage to communicate
>> between the two apps.
>> 
>> https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage
>> 
>>> On Nov 25, 2021, at 1:29 AM, GAbe Barbosa <gb...@gmail.com> wrote:
>>> 
>>> Hi royale folks,
>>> 
>>> I've tried using mx:Modules with no success. I'm trying to come up with
>> an
>>> alternative solution and need help.
>>> 
>>> How would you launch/load an application from the currently running
>>> application at runtime. Ensuring I don't get any duplicate deps is a
>> whole
>>> other problem, so don't worry about that for now.
>>> 
>>> Will be grateful for any ideas, suggestions. Thank you!
>> 
>> 


Re: How to launch mx:Application from another mx:Application at runtime

Posted by GAbe Barbosa <gb...@gmail.com>.
Thanks for responding Harbs!

Could you give me an example of this please. The only way I've been able to
load the other mx:Application is modifying the index.html and adding an
<iframe src='indexOfAnotherApplication.html' > then instantiating the
object via:
    var obj :Object = window.frames["0"]["application"]["path"];
    obj = new obj();

but then fails on adding to the screen via:
    addChild(obj as IUIComponent)

Not sure what you mean by cross-op, but would need the apps to share many
models or singletons.

On Thu, Nov 25, 2021 at 2:48 AM Harbs <ha...@gmail.com> wrote:

> How much cross-op do you need?
>
> I’d probably load it in an iframe you can use either <html:Iframe> or
> <js:WebBrowser>
>
> If you need limited communication, you can use postMessage to communicate
> between the two apps.
>
> https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage
>
> > On Nov 25, 2021, at 1:29 AM, GAbe Barbosa <gb...@gmail.com> wrote:
> >
> > Hi royale folks,
> >
> > I've tried using mx:Modules with no success. I'm trying to come up with
> an
> > alternative solution and need help.
> >
> > How would you launch/load an application from the currently running
> > application at runtime. Ensuring I don't get any duplicate deps is a
> whole
> > other problem, so don't worry about that for now.
> >
> > Will be grateful for any ideas, suggestions. Thank you!
>
>

Re: How to launch mx:Application from another mx:Application at runtime

Posted by Harbs <ha...@gmail.com>.
How much cross-op do you need?

I’d probably load it in an iframe you can use either <html:Iframe> or <js:WebBrowser>

If you need limited communication, you can use postMessage to communicate between the two apps.

https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage

> On Nov 25, 2021, at 1:29 AM, GAbe Barbosa <gb...@gmail.com> wrote:
> 
> Hi royale folks,
> 
> I've tried using mx:Modules with no success. I'm trying to come up with an
> alternative solution and need help.
> 
> How would you launch/load an application from the currently running
> application at runtime. Ensuring I don't get any duplicate deps is a whole
> other problem, so don't worry about that for now.
> 
> Will be grateful for any ideas, suggestions. Thank you!