Skip to content
This repository has been archived by the owner on Jan 5, 2023. It is now read-only.

This library requires Flex #9

Open
thegoldenmule opened this issue Aug 16, 2012 · 20 comments
Open

This library requires Flex #9

thegoldenmule opened this issue Aug 16, 2012 · 20 comments

Comments

@thegoldenmule
Copy link

promise-as3 is a misleading title for this project. Perhaps promise-flex is better? This library requires the Flex framework which a large number of projects do not use do to its massive overhead. Flex is not required for this project, why is it a dependency?

@ThomasBurleson
Copy link
Contributor

@thegoldenmule
The Promise::watch() method provides support to watch an mx.rpc.AsyncToken.
So the Flex framework is used only for that feature. It could be easily disabled and then Flex would no longer be a requirement.

@thegoldenmule
Copy link
Author

That's not quite true. The [Bindable] metadata tag requires the Flex framework.

@pmowrer
Copy link

pmowrer commented Aug 17, 2012

[Bindable] metadata is only relevant to Flex, but its presence shouldn't prevent you from compiling without Flex. The AS3 compiler will just throw out any metadata dags it doesn't recognize.

I'm using promise-as3 in an AS3-only project just fine, without any modifications.

@thegoldenmule
Copy link
Author

My concerns still remain--this library requires Flex, plain and simple. When I try to compile without linking to Flex, it chokes on both the Bindable tags and mx.rpc.AsynchToken.

@ThomasBurleson
Copy link
Contributor

@thegoldenmule
[Bindable] is an absolutely required metadata tag for this library. I believe there is a way to compile AS3-only code and retain the [Bindable] by using the mxml compiler... we just have not done that yet!

@pmowrer
Copy link

pmowrer commented Aug 20, 2012

@thegoldenmule

What AS3 compiler are you using that "chokes" on [Bindable]? AFAIK, you should be able declare any metadata tag you like.

@ThomasBurleson
Copy link
Contributor

@patrick,
Please note that the mxml compiler will scan [Bindable] metadata tags and actually generate source code with getter/setter functions and databinding watchers. This is critical... as just preserving [Bindable] metadata is not sufficient.

@pmowrer
Copy link

pmowrer commented Aug 20, 2012

@ThomasBurleson What I'm saying is that an AS3 compiler should be able to compile code containing any metadata notation without a fuss. Adding [Bindable] metadata to your code doesn't make it dependent on Flex. It merely instructs the Flex compiler to do extra work (as you pointed out) whereas a regular AS3 compiler (such as Flash Pro's) just ignores it.

@thegoldenmule
Copy link
Author

The [Bindable] metatag requires mx.binding.BindingManager.

@pmowrer
Copy link

pmowrer commented Aug 20, 2012

@thegoldenmule My understanding is that metadata is just annotation, nothing else. You could put anything you want inside of metadata brackets and compile it. From an AS3 language standpoint, no dependencies are ever implied by metadata.

However, the compiler you're using may interpret the metadata and perform work. This is what the Flex compiler does, generating code that, among other things, requires mx.binding.BindingManager. An AS3-only compiler won't do this; it's not programmed to interpret [Bindable]. It sounds like you're trying to compile using the Flex (MXMLC) compiler but without linking in Flex libraries. That would cause an error, but that doesn't mean promise-as3 is dependent on Flex. Try using a different compiler.

You can still use the MXMLC compiler to compile this project and use it with an AS3-only project. Typically, the Flex framework is linked in as an external dependency, which means it won't add very much to the SWC size, except for the generated code for binding support. The SWC I've generated this way is about 14kb -- tiny. This SWC will not require the Flex framework to be used within an AS3-only project.

@makc
Copy link

makc commented Sep 11, 2012

Try using a different compiler.

What other compilers are there? Flash CS?

@pmowrer
Copy link

pmowrer commented Oct 8, 2012

There's the Flash CS compiler, the new ASC 2.0, Haxe and possibly others. I'm not suggesting MXMLC isn't fine, it was just for the sake of the argument. Point is, if you're already using MXMLC to compile your AS3 code, you can use this library as-is.

The single dependency from the Flex framework, mx.rpc.AsyncToken, will be compiled in from the framework source, but will have a very small impact on the file size.

@johnyanarella
Copy link
Member

The [Bindable] metadata is no longer used following the Promises/A+ compliant rewrite. (See #2.)

Promise.when() does still reference mx.rpc.AsyncToken, but this can be easily commented out when unavailable.

@johnyanarella
Copy link
Member

We could potentially compare the qualified class name against the String "mx.rpc.AsyncToken" in order to avoid the import and explicit class reference, but I think that would have negative performance implications.

The other option that comes to mind would be conditional compilation, but I think only MXMLC supports that.

pmowrer added a commit to pmowrer/promise-as3 that referenced this issue Mar 14, 2013
@pmowrer
Copy link

pmowrer commented Mar 14, 2013

COMPC also supports conditional compilation. I think that works well to solve this issue. See my commit above.

@darscan
Copy link
Contributor

darscan commented May 17, 2013

I don't believe that conditional compilation is the best solution here - it forces those compilation arguments onto any project that chooses to use this library.

Instead I'd prefer an opt-in (plugin) approach. I'll see what I can come up with.

@johnyanarella
Copy link
Member

Following @darscan's pull request, which has now been integrated, the Promise class is no longer dependent on the Adobe Flex mx.rpc.* classes.

See #12.

@darscan
Copy link
Contributor

darscan commented May 24, 2013

When compiled as a SWC (speaking of which, this library probably needs an Ant build script.. and versioning), this change should allow the library to be used in plain AS3 projects without pulling in Flex. As such, this issue can probably be closed.

@johnyanarella
Copy link
Member

This issue is still open for now, as I'd like to restructure the project similarly to hamcrest-as3 and linkify-as3. This would include:

  • separating the source into src and src-flex,
  • introducing a test runner project,
  • adding an ant script that generates pure as3 vs flex builds, and
  • finally tagging this with a version number.

I welcome pull requests on any of these.

@fwienber
Copy link
Contributor

I'd like to support this idea.
I am evaluating Promise-AS3 to be used with Jangaroo, a compiler from AS3 to JavaScript.
Since your recent rewrite, everything seems to work fine if I leave out mx.rpc.AsyncToken.
So it would also simplify our build process if you separated sources with Flex dependencies!

karfau added a commit to karfau/promise-as3 that referenced this issue Jun 17, 2014
karfau added a commit to karfau/promise-as3 that referenced this issue Jun 17, 2014
- the build.xml was originally created by @ThomasBurleson and modiefied by me
- as I don't know how to get all the changes in from his fork ThomasBurleson/promise-as3 through all those git branches I just started from the current master and did what was suggested in CC-Archived#9 (comment)
@karfau karfau mentioned this issue Jun 17, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants