script.js should contain a function with members instead of global variables.

Bug #1187933 reported by Robert Steckroth
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
slatekit-shell
Confirmed
Medium
Penk Chen

Bug Description

This will necessitate better code design throughout the application.

Penk Chen (penk)
Changed in slatekit-shell:
status: New → Confirmed
importance: Undecided → Medium
assignee: nobody → Ping-Hsun Chen (penk)
Revision history for this message
Penk Chen (penk) wrote :

What's the best practice in QML to handle constants?

Revision history for this message
Robert Steckroth (robertsteckroth) wrote : Re: [Bug 1187933] Re: script.js should contain a function with members instead of global variables.

Well, there is no such thing as constants technically. If you want to
disassociate a variable from the QML, use a function call with variables
declared inside that scope.
Otherwise, the property [type] [name]: value will have to do.
Your script.js can look like this -->
var a = function() {
this.b = "hello world"
}
var c = new a

In the qml, just use the function and members -->
import "script.js" as myA

console.log(c.b) outputs --> "hello world"

i may help with your project this weekend, you have done a great job with
the QML parenting and structure.

On Fri, Jun 7, 2013 at 7:55 AM, Ping-Hsun Chen <email address hidden> wrote:

> What's the best practice in QML to handle constants?
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1187933
>
> Title:
> script.js should contain a function with members instead of global
> variables.
>
> Status in The Web Browser with a Hamburger Button:
> Confirmed
>
> Bug description:
> This will necessitate better code design throughout the application.
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/slatekit-shell/+bug/1187933/+subscriptions
>

--
Bust0ut, Surgemcgee: Systems/Web/Software Engineer

"Freedom is empowered by those without power" - Robert Edward Steckroth II
"Injustice, regarding the internet, is fashioned through laws and
enforcement" - Robert Edward Steckroth II
"Reality is the fuel of the universe and the roadblock to human
understanding" - Robert Edward Steckroth II

Revision history for this message
Robert Steckroth (robertsteckroth) wrote :

Also, are you using Qt Creator? It has a ton of useful feature for this
type of work. CTL+space to auto complete is priceless!

On Fri, Jun 7, 2013 at 8:24 AM, Robert Steckroth
<email address hidden>wrote:

> Well, there is no such thing as constants technically. If you want to
> disassociate a variable from the QML, use a function call with variables
> declared inside that scope.
> Otherwise, the property [type] [name]: value will have to do.
> Your script.js can look like this -->
> var a = function() {
> this.b = "hello world"
> }
> var c = new a
>
>
> In the qml, just use the function and members -->
> import "script.js" as myA
>
> console.log(c.b) outputs --> "hello world"
>
>
> i may help with your project this weekend, you have done a great job with
> the QML parenting and structure.
>
>
>
>
>
>
>
>
>
> On Fri, Jun 7, 2013 at 7:55 AM, Ping-Hsun Chen <email address hidden> wrote:
>
>> What's the best practice in QML to handle constants?
>>
>> --
>> You received this bug notification because you are subscribed to the bug
>> report.
>> https://bugs.launchpad.net/bugs/1187933
>>
>> Title:
>> script.js should contain a function with members instead of global
>> variables.
>>
>> Status in The Web Browser with a Hamburger Button:
>> Confirmed
>>
>> Bug description:
>> This will necessitate better code design throughout the application.
>>
>> To manage notifications about this bug go to:
>> https://bugs.launchpad.net/slatekit-shell/+bug/1187933/+subscriptions
>>
>
>
>
> --
> Bust0ut, Surgemcgee: Systems/Web/Software Engineer
>
> "Freedom is empowered by those without power" - Robert Edward Steckroth II
> "Injustice, regarding the internet, is fashioned through laws and
> enforcement" - Robert Edward Steckroth II
> "Reality is the fuel of the universe and the roadblock to human
> understanding" - Robert Edward Steckroth II
>
>
>

--
Bust0ut, Surgemcgee: Systems/Web/Software Engineer

"Freedom is empowered by those without power" - Robert Edward Steckroth II
"Injustice, regarding the internet, is fashioned through laws and
enforcement" - Robert Edward Steckroth II
"Reality is the fuel of the universe and the roadblock to human
understanding" - Robert Edward Steckroth II

Revision history for this message
Penk Chen (penk) wrote :

Ah thanks for your thoroughly explanation.

No I don't use Qt Creator, mostly just vim over ssh on Vagrant VM.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.