Code Monkey home page Code Monkey logo

Comments (8)

justinmchase avatar justinmchase commented on September 6, 2024 1

Published in v0.1.0

from electron-plugins.

justinmchase avatar justinmchase commented on September 6, 2024

That would probably be ok but you can also add things onto the context.appContext.

var appContext = {
  common: function (dep) { console.log(dep); }
}

loadPlugins({ appContext: appContext }, results, callback);

Then in your plugin:

module.exports = function (context) {

   context.common(this); // do your common stuff here...

};

from electron-plugins.

alvarolorentedev avatar alvarolorentedev commented on September 6, 2024

yes but i am trying to do a crossplatform social network manager, so i need access to a plugin for example to post.
That in my brain feels like a direct request from the app side towards the plugin itself. It feels not natural to do a double indirection to achieve it if i know all my plugins have the same signature.
Thanks for the fast reply 👍

from electron-plugins.

justinmchase avatar justinmchase commented on September 6, 2024

Can you give a little code snippet with what you want to do with it?

from electron-plugins.

alvarolorentedev avatar alvarolorentedev commented on September 6, 2024

yes of course, first of course i will load the plugins and keep a reference to the collection

view.document.addEventListener('DOMContentLoaded', function () {
plugins.load(context, (err, ids, plugins) => {
                if(err)
                    return;
                this.pluginsHolder = plugins;
            });
});

each plugin contains a social network, each of the plugins export a class with the same signature. So i can do something like:

function postData()
{
       for (var i = 0; i < this.pluginsHolder.lenght; ++i) {
                this.pluginsHolder[i].post('Hello World');
       }
}

from electron-plugins.

justinmchase avatar justinmchase commented on September 6, 2024

Oh ok! I'm glad you provided that snippet. You're just saying that you want the modules to also be added as a parameter to the callback?

e.g.

callback(null, dependencies, modules)

That would be pretty easy and backward compatible if you say yes I can publish this change pretty fast.

from electron-plugins.

alvarolorentedev avatar alvarolorentedev commented on September 6, 2024

yes that us exactly what i was thinking about :). if you publish that change it will be really helpful for me.

from electron-plugins.

alvarolorentedev avatar alvarolorentedev commented on September 6, 2024

thanks a lot :)

from electron-plugins.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.