coroutine not found for KMongo - kotlin backend with jwt - intellij-idea

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

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";

Implementing Listener into a java - Kotlin plugin

Im trying to create a Minecraft Plugin using Kotlin, I converted the project to kotlin and did all the necessary stuff, I created an event listener but havent figured how to implement the Listener interface.
import org.bukkit.Material
import org.bukkit.entity.Creeper
import org.bukkit.entity.Skeleton
import org.bukkit.entity.Zombie
import org.bukkit.event.EventHandler
import org.bukkit.event.entity.EntitySpawnEvent
import org.bukkit.inventory.ItemStack
import java.net.http.WebSocket.Listener
class MobSpawnEvent : Listener {
}
that's what I tried but it doesnt seem to work as my Main.class file says "Make MobSpawnEvent implement org.bukkit.listener"
I tried using the " : " operator but it didnt work
You are not importing the good class. java.net.http.WebSocket.Listener isn't from spigot, you should replace it by org.bukkit.listener.

Nuxt import highcharts for client side only

In my vue app I had following import in my component
import Highcharts from "highcharts";
import treemapInit from "highcharts/modules/treemap";
treemapInit(Highcharts);
Now I have nuxt and I need to import this part only for client side, because it fails with an error on server-side.
How to do this? Please don't suggest me Nuxt plugins, since I want to use it local due to performance.
Thanks!
The code executes twice - on server-side and then on client-side. The first run is done in an environment that lacks window and causes Highcharts to be loaded, but not initialized. The fix is to place all modules inits in if checking if Highcharts is an object or a function. It should be an object for module initialization:
import Highcharts from "highcharts";
import treemapInit from "highcharts/modules/treemap";
if (typeof Highcharts === "object") {
treemapInit(Highcharts);
}
Docs: https://github.com/highcharts/highcharts-vue#readme
Similar thread: https://github.com/highcharts/highcharts-vue/issues/73

How can I import lodash with svelte?

I simply wanted to import lodash import _ from 'lodash';, and I keep having the following error:
rollup v2.23.0
bundles src/main.js → public\build\bundle.js...
[!] (plugin commonjs) SyntaxError: Unexpected token (434:48) in C:\my-svelte\node_modules\lodash\lodash.js
node_modules\lodash\lodash.js (434:48)
432:
433: /** Detect free variable `process` from Node.js. */
434: var freeProcess = moduleExports && freeGlobal.process;
^
435:
436: /** Used to access faster Node.js helpers. */
SyntaxError: Unexpected token (434:48) in C:\my-svelte\node_modules\lodash\lodash.js
at Object.pp$4.raise (C:\my-svelte\node_modules\rollup\dist\shared\rollup.js:15135:13)
at Object.pp.unexpected (C:\my-svelte\node_modules\rollup\dist\shared\rollup.js:12906:8)
at Object.pp$3.parseIdent (C:\my-svelte\node_modules\rollup\dist\shared\rollup.js:15086:10)
at Object.parseIdent (C:\my-svelte\node_modules\rollup\dist\shared\rollup.js:18737:27)
at Object.parseIdent (C:\my-svelte\node_modules\rollup\dist\shared\rollup.js:18969:27)
at Object.pp$3.parseSubscript (C:\my-svelte\node_modules\rollup\dist\shared\rollup.js:14380:62)
at Object.parseSubscript (C:\my-svelte\node_modules\rollup\dist\shared\rollup.js:18640:37)
at Object.pp$3.parseSubscripts (C:\my-svelte\node_modules\rollup\dist\shared\rollup.js:14355:24)
at Object.pp$3.parseExprSubscripts (C:\my-svelte\node_modules\rollup\dist\shared\rollup.js:14340:21)
at Object.pp$3.parseMaybeUnary (C:\my-svelte\node_modules\rollup\dist\shared\rollup.js:14314:17)
I used npx degit sveltejs/template my-svelte to create the app.
I tried lodash-es as well, same thing: [!] (plugin commonjs) SyntaxError: Unexpected token (13:46) in C:\my-svelte\node_modules\lodash-es_nodeUtil.js.
This is definitely a lodash related issue, specifically related to that line 434. Everything else I tried to import works just fine:
import {v4} from 'uuid';
import {Subject} from "rxjs";
import ReconnectingWebSocket from 'reconnecting-websocket';
...
EDIT: The problem is caused by import replace from '#rollup/plugin-replace'; in rollup.config.js :(
Now I need to figure out how to get .env variables into Svelte without #rollup/plugin-replace...
I use lodash-es and works fine. I even get nice tree-shaking with that.
<script>
import { upperCase } from 'lodash-es';
export let name;
</script>
<p>{upperCase(name)}</p>
Edit
The answer was pretty old and code improves: my application now uses this to import lodash on a svelte file for quite a while - I hope it works for the OP also now:
import _ from "lodash";
Old Post
(a commenter mentioned that this does not work anymore, for whatever reasons - I leave it just here)
This works for me in my svelte files:
<script>
const _ = require('lodash');
//...
</script>
I often get into trouble with import on my electron/svelte project but require usually helps.

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