cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shazron <shaz...@gmail.com>
Subject Re: golang based plugins
Date Wed, 04 Jan 2017 01:24:53 GMT
I can only speak for iOS, but in the generated project code there is this
method you can override:
https://github.com/apache/cordova-ios/blob/69e06b0a854e5a566b38dd021bcdca0e2f65947c/bin/templates/project/__PROJECT_NAME__/Classes/MainViewController.m#L146

Parse what type of command there, and handle it. I suppose you could add a
prefix for the Service for GoLang plugin code to differentiate. If you
don't handle it, let Cordova handle it.


On Thu, Dec 29, 2016 at 1:17 PM, Ged Wed <gedw99@gmail.com> wrote:

> I am considered writing plugins  in golang ?
> I dont know enough about the internals of Cordova to estimate some of the
> work involved, and am looking for any feedback from others before writing
> this.
>
> The nature of the plugin API being so simple makes it very easy to be
> supported on obth Mobile and desktop.
>
> cordova.exec(function(winParam) {},
>              function(error) {},
>              "service",
>              "action",
>              ["firstArgument", "secondArgument", 42, false]);
>
>
> All that is needed is a pass through layer be written for IOS and android
> once, and never again.
> Once the pass through layr is written, all golang developers just write
> their plugins in golang.
> For Android a standard java layer passes the cordova.exec call to the
> golang binding.
> For IOS, its exactly same. an Objective C layer, that simple passes the
> cordova.exe call to the golang binding.
>
> At the golang level you just need to implement the same interface as
> cordova
> .exec
> Then the golang code  just does a switch on the Service and Action, and
> retusn the result.
> At this level you can use any golang embedded database (indexdb, bolt, etc)
> and any golang code pretty much.
>
> For the golang developer, compiling on mobile is always "gomobile build
> --target=android", which produces an android gradle project
> For IOS, its "gomobile build --target=ios", which produce a Framework
> project.
>
> For Desktop, its exactyl the same approach as for Mobile.
>
> Please let me knwo your thoughts
>
> thanks in advance ..
>
> Ged
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message