Small string manipulation utilities in QtQuick: better a QML singleton or a js file?
-
We often need to include in our apps small string manipulation functions (usually 4-5 lines of code) that are used in several places. Is it better to have them in a QML singleton or in a JS file? And why? Thank you
-
thanks @mcosta
-
@mcosta On the other hand, I am also considering the following advice:
http://doc.qt.io/qt-5/qtquick-performance.html#use-singleton-types-instead-of-pragma-library-scripts
not sure whether it is written with atomic properties in mind or also JS functions
-
HI,
In the link is written
If you are using a pragma library script to store application-wide instance data,
you was talking about small functions.
Obviously if you need to store data (like models, or application-wide data) QObject singleton is the best solution
-
@mcosta wouldn't making the library pragma be advisable in any case, since I am going to call it from several QML files?