EddyVerbruggen / nativescript-printer

:fax: Send an image or the screen contents to a physical printer
MIT License
36 stars 13 forks source link

JS ERROR TypeError: Object is not a constructor #11

Closed d3mac123 closed 6 years ago

d3mac123 commented 6 years ago

Hi, I am trying to using the plugin with plain Javascript. However, writing this:

var Printer = require("nativescript-printer")
var printer = new Printer();

I am getting the following error:

***** Fatal JavaScript exception - application has been terminated. *****
Native stack trace:
1   0x10748478b NativeScript::FFICallback<NativeScript::ObjCMethodCallback>::ffiClosureCallback(ffi_cif*, void*, void**, void*)
2   0x107b2810e ffi_closure_unix64_inner
3   0x107b28a52 ffi_closure_unix64
4   0x10862d097 -[UIResponder touchesEnded:withEvent:]
5   0x10862cfcd forwardTouchMethod
6   0x10862d097 -[UIResponder touchesEnded:withEvent:]
7   0x10862cfcd forwardTouchMethod
8   0x10862d097 -[UIResponder touchesEnded:withEvent:]
9   0x1089ebbad _UIGestureEnvironmentSortAndSendDelayedTouches
10  0x1089e5a4d _UIGestureEnvironmentUpdate
11  0x1089e541f -[UIGestureEnvironment _deliverEvent:toGestureRecognizers:usingBlock:]
12  0x1089e44cb -[UIGestureEnvironment _updateGesturesForEvent:window:]
13  0x108472f14 -[UIWindow sendEvent:]
14  0x108416365 -[UIApplication sendEvent:]
15  0x108d62a1d __dispatchPreprocessedEventFromEventQueue
16  0x108d65672 __handleEventQueueInternal
17  0x10baaf101 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
18  0x10bb4ef71 __CFRunLoopDoSource0
19  0x10ba93a19 __CFRunLoopDoSources0
20  0x10ba92fff __CFRunLoopRun
21  0x10ba92889 CFRunLoopRunSpecific
22  0x10d0c29c6 GSEventRunModal
23  0x1083fa5d6 UIApplicationMain
24  0x107b288ad ffi_call_unix64
25  0x12bbaaf70
JavaScript stack trace:
1   anonymous@file:///app/flight-page.js:27:26
2   evaluate@[native code]
3   moduleEvaluation@[native code]
4   @[native code]
5   promiseReactionJob@[native code]
6   require@[native code]
7   _loop_1@file:///app/tns_modules/tns-core-modules/globals/globals.js:60:30
8   loadModule@file:///app/tns_modules/tns-core-modules/globals/globals.js:68:30
9   @file:///app/tns_modules/tns-core-modules/ui/frame/frame-common.js:82:37
10  @file:///app/tns_modules/tns-core-modules/ui/frame/frame-common.js:108:43
11  navigate@file:///app/tns_modules/tns-core-modules/ui/frame/frame-common.js:213:48
12  listViewItemTap@file:///app/flights-page.js:445:34
13  notify@file:///app/tns_modules/tns-core-modules/data/observable/observable.js:103:31
14  touchesEndedWithEvent@file:///app/tns_modules/nativescript-pro-ui/listview/listview.js:743:29
15  UIApplicationMain@[native code]
16  start@file:///app/tns_modules/tns-core-modules/application/application.js:235:26
17  anonymous@file:///app/app.js:257:22
18  evaluate@[native code]
19  moduleEvaluation@[native code]
20  @[native code]
21  promiseReactionJob@[native code]
JavaScript error:
file:///app/flight-page.js:27:26: JS ERROR TypeError: Object is not a constructor (evaluating 'new Printer()')

Any ideas on how to fix it?

EddyVerbruggen commented 6 years ago

With JavaScript it should be:

var printerPlugin = require("nativescript-printer")
var printer = new printerPlugin.Printer();