Adding an optional Import statement - qml

In QML-only application (so no backend) I'd like to have an optional import of a javascript file. If the optional library is present then the user has extra functionalities.
A regular:
import "xyz.js" as SoloAnalyzer
fails if the library is not found.
A try/catch is not valid on import statements:
try {
import "xyz.js" as SoloAnalyzer
}
What are the other options ? Thanks.
IMPORTANT: I'm limited to these versions : QtQuick 2.9 and QtQuick.Controls 2.2

Related

Undefined when import methods from '#videosdk.live/react-native-sdk'

For my RN project, I use '#videosdk.live/react-native-sdk'.When I try to import a method from the library I get undefined. I can't figure out what's going on. I did everything according to the instruction and set it up correctly.
The problem is not even in the setup, but I installed the package '#videosdk.live/react-native-sdk', but I can't import methods from it.
import VideoSdk from '#videosdk.live/react-native-sdk'; I used this import but got undefined
You can't import VideoSdk. You need to import some other components like:
import {
MeetingProvider,
useMeeting,
useParticipant,
MediaStream,
RTCView,
} from "#videosdk.live/react-native-sdk";

coroutine not found for KMongo - kotlin backend with jwt

I am trying to implement kotlin backend with mongo DB and JWT, all requried dependencies are added as
ktor_version=2.1.0
kmongo_version=4.7.0
commons_codec_version=1.15
kotlin_version=1.6.21
logback_version=1.2.11
kotlin.code.style=official
But unable to get import for .coroutine
KMongo.createClient(connectionString = "....").coroutine.getDatabaseName(dbName)
error is still there even though the import is set manually
import org.litote.kmongo.coroutine.coroutine
Gradle dependencies:
implementation("io.ktor:ktor-server-call-logging-jvm:$ktor_version")
implementation("io.ktor:ktor-server-content-negotiation-jvm:$ktor_version")
implementation("io.ktor:ktor-server-core-jvm:$ktor_version")
implementation("io.ktor:ktor-serialization-kotlinx-json-jvm:$ktor_version")
implementation("io.ktor:ktor-server-auth-jvm:$ktor_version")
implementation("io.ktor:ktor-server-auth-jwt-jvm:$ktor_version")
implementation("io.ktor:ktor-server-netty-jvm:$ktor_version")
implementation("ch.qos.logback:logback-classic:$logback_version")
testImplementation("io.ktor:ktor-server-tests-jvm:$ktor_version")
testImplementation("org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version")
implementation("org.litote.kmongo:kmongo:$kmongo_version")
implementation("org.litote.kmongo:kmongo-coroutine:$kmongo_version")
implementation("commons-codec:commons-codec:$commons_codec_version")
For KMongo, have to use following import
import org.litote.kmongo.reactivestreams.KMongo
Instead of
import org.litote.kmongo.KMongo

Vue project cannot resolve '#'

My vue-cli version is 4.5.15, but it cannot resolve # as ./src and all paths using '#' are not found. Why did this happen and how could I solve it?
Your statement tries to import a file which does not exist: import Layout from '#/layout' would work with layout.vue or layout/index.js, neither of which is present.
To fix this, you can either import the single components with their full path (as mentioned in #wittgenstein's comment): import Footer from '#/layout/Footer'
Or you can create layout/index.js which exposes all components inside the directory:
import Footer from './Footer.vue'
import Header from './Header.vue'
// ...
export default {
Footer, Header, // ...
}
Then you can import components like that: import { Footer, Header } from '#/layout'
It is not possible to import a folder, you will have to import a single file from the layout folder:
import Footer from "#/Layout/Footer.vue"
import Header from "#/Layout/Header.vue"
import Index from "#/Layout/Index.vue"
import Sidebar from "#/Layout/Sidebar.vue"
import Sidebar2 from "#/Layout/Sidebar2.vue"
If you want to import every file, you will have to this all manually, because you cannot import a folder.
Hope this will work for you!
I have known what the problem is. It's because I used 'Index.vue' as the name before and git is insensitive to capital. So it cannot find the path.
Vue has supported
import xxx from "#/xxx"
if the name of your file you want to import is "index.vue".
Thanks a lot for your answers!

Import flow types from react-native

I am trying to use flow in my current react-native project. After some research, I discovered that all the types I need are in this file, but I have no idea how I am supposed to import these types.
For instance, I need to import the ViewLayoutEvent from there. What am I supposed to write in my file?
I tried the following:
import type { ViewLayoutEvent } from 'react-native';
import type { ViewLayoutEvent } from 'react-native/Libraries/Components/View/ViewPropTypes';
To no avail.
Update:
Or maybe it is in this file

IntelliJ Reformat Settings

For my Flutter project, I have my dependencies setup as such:
// Dependencies
// ------------
// Packages
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:firebase_auth/firebase_auth.dart';
// Widgets
import '../widgets/ring-swipe.dart';
However, when I use Reformat Code in IntelliJ, my comments turn into:
// Dependencies
// ------------
// Packages
import 'package:cached_network_image/cached_network_image.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import '../widgets/ring-swipe.dart';
I can't seem to find where this setting is set for Dart/Flutter projects. Is this non-configurable?
This behavior seems related to issue IDEA-171179 (and duplicates), which is still open, unfortunately.
See, specifically, this Dart example, which seems to match.
Before reformat code:
// ignore: unused_import
import 'package:polymer_elements/iron_flex_layout_classes.dart';
// ignore: unused_import
import 'package:polymer_elements/app_layout/app_header/app_header.dart';
After reformat code:
import 'package:polymer_elements/iron_flex_layout_classes.dart';
import 'package:polymer_elements/app_layout/app_header/app_header.dart';
// ignore: unused_import
// ignore: unused_import
Valid for the old IDEA 2017.1
To mitigate the issue, remove the Optimize imports check.