{"_id":"@bitmechanics/peak-userland","_rev":"5-1f1f28b857f37f0145f0e3f47814d119","name":"@bitmechanics/peak-userland","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@bitmechanics/peak-userland","version":"1.0.0","description":"","main":"peak-userland.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"author":{"name":"Robin Reiter & Matthias Hermann"},"_id":"@bitmechanics/peak-userland@1.0.0","_shasum":"25b61b9a61df30d8be8a1ca291a264c789eac557","_from":".","_npmVersion":"3.3.12","_nodeVersion":"5.1.0","_npmUser":{"name":"twittadrock","email":"ubootfenster@googlemail.com"},"dist":{"shasum":"25b61b9a61df30d8be8a1ca291a264c789eac557","tarball":"https://registry.npmjs.org/@bitmechanics/peak-userland/-/peak-userland-1.0.0.tgz","integrity":"sha512-jqwXu5LITNckKWr9VVA8+A2NKtoUsONUrizUvX6yCvltOCHfKtsn6OQevpRrB8uC70UAubcnZ/i6lihQ47nW1g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFvpfrsm9aPMBw24ltgMrNMzmVtOEh48RIlkTgDS4c4eAiEA97K5V8/BYFGEFminDBpBGl5t69kxuIQv4VRvNQCZRgU="}]},"maintainers":[{"name":"twittadrock","email":"ubootfenster@googlemail.com"}],"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/peak-userland-1.0.0.tgz_1463416098531_0.16294224793091416"}},"1.0.1":{"name":"@bitmechanics/peak-userland","version":"1.0.1","description":"## Installation ##","main":"peak-userland.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"author":{"name":"Robin Reiter & Matthias Hermann"},"_id":"@bitmechanics/peak-userland@1.0.1","_shasum":"5b08a46dd80c81bf06618ceda74b157b508e0590","_from":".","_npmVersion":"3.7.5","_nodeVersion":"6.2.0","_npmUser":{"name":"robin7331","email":"robin@bitmechanics.de"},"dist":{"shasum":"5b08a46dd80c81bf06618ceda74b157b508e0590","tarball":"https://registry.npmjs.org/@bitmechanics/peak-userland/-/peak-userland-1.0.1.tgz","integrity":"sha512-yG6viNAGGmMkAMOm0h0FCZIABtWg2/XGsj3cFCnc448ZXe1xsWUrgj4rubo22ATwNsCarHnfIIqwZ7UTCi8uWw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHaesowFHVK/2RAYXxLQU40GqONU5kf+J6aeeMmbUTAgAiEAzmaYU27+jMCoibHHosvWshKMT1PfdUEmGdvezgYV5p8="}]},"maintainers":[{"name":"robin7331","email":"robin@bitmechanics.de"},{"name":"twittadrock","email":"ubootfenster@googlemail.com"}],"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/peak-userland-1.0.1.tgz_1465927778796_0.41101393452845514"}}},"readme":"# PEAK Userland #\n\n## Installation ##\n\n1. Add the peak userland Library to your JS project via NPM ```npm install @bitmechanics/peak-userland --save```\n2. Use this module in peak:\n\n```\n#!javascript\n\nconst methodDefinitions = require('./method-definitions');\nconst peakUserland = peak.useModule(require('@bitmechanics/peak-userland'), methodDefinitions);\n```\n\n## Method definitions ##\n\nDefine all the methods, that you need in this particular App.\nIn this example we will build an mobile App that has a calculator functionality.\nThis calculator stores the latest result in the App bundle.\n\nWe might need ```clear()``` as a JS function to reset the calculator and ```storeResult(result) aswell as getLastResult()``` as native methods.\n\nOur method-definitions.js file will look like this:\n\n```\n#!javascript\n\nmodule.exports = {\n   native: [\n      {\n      \tname: 'storeResult',\t\t\n      \tpayloadType: 'number'\n      },\n      {\n        name: 'getLastResult',\n        callbackDataType: 'number'\n      }\n   ],\n   js: [\n      {\n         name: 'clear'\n      },\n      {\n         name: 'getCurrentResult',\n         callbackDataType: 'number'\n      }\n   ]\n}\n```\n\n\nIn our App we now need to implement these functions.\n\n\n## Implement JS Functions ##\n\nWe only have one JS function, this could be implemented like this:\n\n\n```\n#!javascript\n\n\nnew Vue({\n\n   ready() {\n     \n      const userland = peak.modules.peakUserland // grab a reference to the userland module\n      userland.bind('clear', this.clearUI)       // 'bind' this.clearUI to the defined method definition. This method can now be called from native.\n      userland.bind('getCurrentResult', this.getCurrentResult)\n\n      // After binding a method, you could also access it through:\n      userland.clear()\n     \n   },\n\n   methods: {\n\n      clearUI() {\n         this.result = ''\n         this.steps = []\n         ...\n         this.peak.info(\"results cleared!\")     // You can always access the logger via this.peak.info or this.peak.error (or this.peak.logger)\n      },\n      getCurrentResult(callback) {\n         callback(this.result);\n      }\n   }\n})\n\n```\n\n## Call native methods ##","maintainers":[{"email":"ubootfenster@googlemail.com","name":"twittadrock"},{"email":"robin@bitmechanics.de","name":"robin7331"}],"time":{"modified":"2022-06-12T15:20:15.059Z","created":"2016-05-16T16:28:20.548Z","1.0.0":"2016-05-16T16:28:20.548Z","1.0.1":"2016-06-14T18:09:42.313Z"},"author":{"name":"Robin Reiter & Matthias Hermann"},"readmeFilename":"README.md","description":"## Installation ##"}