npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

brig-module

v0.0.1

Published

Framework to implement module for Brig

Downloads

5

Readme

brig-module

Module framework for brig, to let developer implement own module for brig easily.

NPM NPM

Installation

Install module via NPM

npm install brig-module

Create Your NPM module for brig

With brig-module, you can create useful brig module which can be packaged and published to NPM server.

First Step

The first step is making preparation for your own NPM package. Create a project which includes structure:

  • types/
    • MyItem.js
  • index.js
  • package.json
  • README.md

Note that: If you don't know how to package a NPM module, please go to NPM official website to learn more.

Second Step

The entry of this NPM module is index.js, it should contains:

index.js

var BrigModule = require('brig-module');

var brigModule = new BrigModule();

brigModule.addType(require('./types/MyItem'));

module.export = brigModule;

Third Step: Create customized type

Implement your QML type by using BrigModule.TypePrototype.

types/MyItem.js

var BrigModule = require('brig-module');

// Create prototype of type named MyItem
var proto = module.exports = new BrigModule.TypePrototype('MyItem');

// This type has a property named msg, which has default value.
proto.defineProperty('msg', 'hello');

// This type has a method named sum, which has two parameters
proto.defineMethod('sum(a,b)', function(a, b) {
	return a + b;
});

// instance of type was created
proto.on('instance-created', function(instance) {

	instance.on('msgChanged', function() {
    console.log('msg was changed, new value is ' + insntace.getProperty('msg'));
	});

});

Fourth Step: Package and publish your module

Now you can package your brig module which contains your customized type. Using NPM command to make a link or upload package to NPM server.

npm publish

Fifth Step: Using your module and customized QML type in your application

Load your module in your brig application:

app.js

const Brig = require('brig');
const brigMyItem = require('brig-myitem');

const brig = new Brig();

brig.on('ready', (brig) => {

  // Load your module
  brig.loadModule(brigMyItem);
  
  brig.open('Application.qml', (err, window) => {
    // You have a window here
  });
});

Then your customized QML type can be used in QML enviromnet:

Application.js

import QtQuick 2.3
import QtQuick.Controls 2.0
import Brig.MyItem 1.0

ApplicationWindow {
	visible: true;
	color: 'black';
	title: 'My Application';
	width: 1280;
	height: 768;

	MyItem {
		id: myItem;
		msg: 'new msg';
	}
  
	Component.onCompleted: {
		var ret = myItem.sum(1, 2);
		console.log(ret);
	}
}

License

Licensed under the MIT License

Authors

Copyright(c) 2017 Fred Chien <[email protected]>