Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including seaport-bridge with all npm packages installed. Try it out:

var seaportBridge = require("seaport-bridge")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

seaport-bridge v0.2.2

Seaport UIWebView javascript bridge

Seaport UIWebView javascript bridge

Usage


var seaport = require('seaport-bridge');

seaport.connect(function dataHandler(data) {

  console.log('receive data:' + data);

}, function connected(bridge) {

  var userDefaults = bridge.userDefaults;

  userDefaults.set('username', 'ltebean');

  userDefaults.get('username', function(val) {
    console.log(val);
  })

  var http = bridge.http;
  http.get({
    domain: 'ltebean.apiary.io',
    path: '/notes/1',
    cookies: {},
  }, function(data) {
    console.log(JSON.stringify(data));
  });

  http.post({
    domain: 'ltebean.apiary.io',
    path: '/updates',
    body: {
      content: 'haha'
    },
    cookies: {},
  }, function(data) {
    console.log(JSON.stringify(data));
  })


  bridge.param.get('city', function(data) {
    console.log(JSON.stringify(data))
  })

  bridge.data.send({
    segue: 'detail',
    param: {
      name: 'ltebean'
    }
  });

})
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free