How to use the bindings.NativeEmitter function in bindings

To help you get started, we’ve selected a few bindings examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NickNaso / addon-event-emitter / 01 / index.js View on Github external
* THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS
 * OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY
 * IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
 * MERCHANTABLITY OR NON-INFRINGEMENT.
 *
 * See the Apache Version 2.0 License for specific language governing
 * permissions and limitations under the License.
 *
 * Contributors - initial API implementation:
 * Nicola Del Gobbo 
 ******************************************************************************/

'use strict'

const EventEmitter = require('events').EventEmitter
const NativeEmitter = require('bindings')('native_emitter').NativeEmitter
const inherits = require('util').inherits

inherits(NativeEmitter, EventEmitter)

const emitter = new NativeEmitter()

emitter.on('start', () => {
    console.log('### START ...')
})

emitter.on('data', (evt) => {
    console.log(evt)
})

emitter.on('end', () => {
    console.log('### END ###')
github nodejs / node-addon-examples / inherits_from_event_emitter / node-addon-api / index.js View on Github external
'use strict'

const EventEmitter = require('events').EventEmitter
const NativeEmitter = require('bindings')('native_emitter').NativeEmitter
const inherits = require('util').inherits

inherits(NativeEmitter, EventEmitter)

const emitter = new NativeEmitter()

emitter.on('start', () => {
    console.log('### START ...')
})

emitter.on('data', (evt) => {
    console.log(evt)
})

emitter.on('end', () => {
    console.log('### END ###')