Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ApplicationParametersBead #129

Closed
Harbs opened this issue Mar 16, 2018 · 5 comments
Closed

Add ApplicationParametersBead #129

Harbs opened this issue Mar 16, 2018 · 5 comments

Comments

@Harbs
Copy link
Contributor

Harbs commented Mar 16, 2018

We added two beads in a52284c

ApplicationParametersBead retrieves url parameters specified when loading the app.
ApplicationParametersCaseInsensitiveBead is similar, but the url parameter keys are case insensitive.

@Harbs
Copy link
Contributor Author

Harbs commented Mar 16, 2018

Here’s a distilled example of how to use these beads:

<js:Application xmlns:js="library://ns.apache.org/royale/basic">
  <js:beads> 
    <js:ApplicationParametersCaseInsensitive id="parameters" />
  </js:beads>
  <js:initialView>
    <js:View/>
  </js:initialView>
</js:Application>

And assuming “app" is a reference to your main class you can get values like this:

var myVal:String = app.parameters.getValue("some_val”);

@Harbs Harbs closed this as completed Mar 16, 2018
@piotrzarzycki21
Copy link
Member

@Harbs that bead is quite handy :) What do you think to have such example in the ASDoc on top of the class or maybe as a blog post on Royale website!

@Harbs
Copy link
Contributor Author

Harbs commented Mar 16, 2018

Including use examples in ASDoc is probably a very good idea. Blog post too.

FYI, the bead can probably be attached to any strand in the app. It should not need to be the main class.

@aharui
Copy link
Contributor

aharui commented Mar 16, 2018 via email

@Harbs
Copy link
Contributor Author

Harbs commented Mar 17, 2018

URLParameterBead:

  1. Subclasses EventDispatcher
  2. emits ready events
  3. Returns the raw url parameters

ApplicationParametersBead:

  1. Does not subclass anything
  2. Does not dispatch any events
  3. Parses the url parameters once and has a method for returning values from keys.

I think URLParameterBead is best for urls which might change after the app is loaded (i.e. routing)
I think ApplicationParametersBead is best for static values which don't change and fit a simple key/value pair pattern. (i.e. not hash tags and the like)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants