krushkamx / nativescript-hprt

Print to thermal printers from HPRT in your Nativescript application https://www.hprt.com/
MIT License
29 stars 16 forks source link

Isn't support vanilla Nativescript? #2

Closed yclau closed 5 years ago

yclau commented 6 years ago

Hi, I using hprt plugin in valilla nativescript but the error occur. But I try in angular nativescript, it work.

"nativescript": {
    "id": "org.nativescript.testing",
    "tns-android": {
      "version": "3.4.1"
    }
  },
  "dependencies": {
    "nativescript-hprt": "^0.9.7",
    "nativescript-pro-ui": "^3.3.0",
    "nativescript-theme-core": "~1.0.4",
    "tns-core-modules": "~3.4.0"
  }

var Hprt= require("nativescript-hprt");

I just put inside this code then error occur.

System.err: java.lang.RuntimeException: Unable to start activity ComponentInfo{org.nativescript.testing/com.tns.NativeScriptActivity}: com.tns.NativeScriptException: Failed to find module: "rxjs/Observable", relative to: app/tns_modules/
System.err:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2464)
System.err:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2524)
System.err:     at android.app.ActivityThread.access$900(ActivityThread.java:154)
System.err:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1391)
System.err:     at android.os.Handler.dispatchMessage(Handler.java:102)
System.err:     at android.os.Looper.loop(Looper.java:224)
System.err:     at android.app.ActivityThread.main(ActivityThread.java:5526)
System.err:     at java.lang.reflect.Method.invoke(Native Method)
System.err:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
davorpeic commented 6 years ago

Hi @yclau I don't have much experience with vanilla NS, Can you try importing observable from rxjs library and see if that fix the issue?

yclau commented 6 years ago

After I change the code , it work fine.

file : hprt.android.js Previous code

var Observable_1 = require("rxjs/Observable");
require("rxjs/add/operator/distinctUntilChanged");

I change

var Observable_1 = require("data/observable");
//require("rxjs/add/operator/distinctUntilChanged");

But at important part, what is the require("rxjs/add/operator/distinctUntilChanged"); mean ?

davorpeic commented 5 years ago

@yclau not sure, I guess it is some rxjs functionality. Glad you sorted it out