-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
3a4cb4c8.713c5d5a.js
1 lines (1 loc) · 4.83 KB
/
3a4cb4c8.713c5d5a.js
1
(window.webpackJsonp=window.webpackJsonp||[]).push([[19],{119:function(e,t,a){"use strict";a.d(t,"a",(function(){return u})),a.d(t,"b",(function(){return d}));var r=a(0),n=a.n(r);function c(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function o(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,r)}return a}function s(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?o(Object(a),!0).forEach((function(t){c(e,t,a[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):o(Object(a)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))}))}return e}function l(e,t){if(null==e)return{};var a,r,n=function(e,t){if(null==e)return{};var a,r,n={},c=Object.keys(e);for(r=0;r<c.length;r++)a=c[r],t.indexOf(a)>=0||(n[a]=e[a]);return n}(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(r=0;r<c.length;r++)a=c[r],t.indexOf(a)>=0||Object.prototype.propertyIsEnumerable.call(e,a)&&(n[a]=e[a])}return n}var i=n.a.createContext({}),p=function(e){var t=n.a.useContext(i),a=t;return e&&(a="function"==typeof e?e(t):s(s({},t),e)),a},u=function(e){var t=p(e.components);return n.a.createElement(i.Provider,{value:t},e.children)},b={inlineCode:"code",wrapper:function(e){var t=e.children;return n.a.createElement(n.a.Fragment,{},t)}},m=n.a.forwardRef((function(e,t){var a=e.components,r=e.mdxType,c=e.originalType,o=e.parentName,i=l(e,["components","mdxType","originalType","parentName"]),u=p(a),m=r,d=u["".concat(o,".").concat(m)]||u[m]||b[m]||c;return a?n.a.createElement(d,s(s({ref:t},i),{},{components:a})):n.a.createElement(d,s({ref:t},i))}));function d(e,t){var a=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var c=a.length,o=new Array(c);o[0]=m;var s={};for(var l in t)hasOwnProperty.call(t,l)&&(s[l]=t[l]);s.originalType=e,s.mdxType="string"==typeof e?e:r,o[1]=s;for(var i=2;i<c;i++)o[i]=a[i];return n.a.createElement.apply(null,o)}return n.a.createElement.apply(null,a)}m.displayName="MDXCreateElement"},87:function(e,t,a){"use strict";a.r(t),a.d(t,"frontMatter",(function(){return s})),a.d(t,"metadata",(function(){return l})),a.d(t,"toc",(function(){return i})),a.d(t,"default",(function(){return u}));var r=a(3),n=a(7),c=(a(0),a(119)),o=["components"],s={title:"Using ScalaPB with Scala.js",sidebar_label:"Scala.js"},l={unversionedId:"scala.js",id:"scala.js",isDocsHomePage:!1,title:"Using ScalaPB with Scala.js",description:"Scala.js compiles Scala source code to equivalent",source:"@site/../docs/target/mdoc/scala.js.md",slug:"/scala.js",permalink:"/docs/scala.js",version:"current",sidebar_label:"Scala.js",sidebar:"someSidebar",previous:{title:"gRPC",permalink:"/docs/grpc"},next:{title:"Using ScalaPB with Spark",permalink:"/docs/sparksql"}},i=[{value:"Getting Started",id:"getting-started",children:[]},{value:"Demo",id:"demo",children:[]}],p={toc:i};function u(e){var t=e.components,a=Object(n.a)(e,o);return Object(c.b)("wrapper",Object(r.a)({},p,a,{components:t,mdxType:"MDXLayout"}),Object(c.b)("p",null,Object(c.b)("a",{parentName:"p",href:"http://scala-js.org"},"Scala.js")," compiles Scala source code to equivalent\nJavascript code. It is possible to use ScalaPB generated case classes and\nlenses in Scala.js, and even serialize and parse byte arrays."),Object(c.b)("p",null,"Limitations:"),Object(c.b)("ul",null,Object(c.b)("li",{parentName:"ul"},"The Java protocol buffers are unavailable, and therefore Java conversions\nand Java descriptors do not work (though Scala descriptors in ScalaPB >=\n0.6.0 would cover most use cases)")),Object(c.b)("h2",{id:"getting-started"},"Getting Started"),Object(c.b)("p",null,"Add to your library dependencies:"),Object(c.b)("pre",null,Object(c.b)("code",{parentName:"pre"},'libraryDependencies ++= Seq(\n "com.thesamet.scalapb" %%% "scalapb-runtime" % scalapb.compiler.Version.scalapbVersion,\n\n // The following needed only if you include scalapb/scalapb.proto:\n "com.thesamet.scalapb" %%% "scalapb-runtime" % scalapb.compiler.Version.scalapbVersion % "protobuf"\n)\n')),Object(c.b)("h2",{id:"demo"},"Demo"),Object(c.b)("p",null,"Example project: ",Object(c.b)("a",{parentName:"p",href:"https://github.com/thesamet/scalapbjs-test"},"https://github.com/thesamet/scalapbjs-test")),Object(c.b)("p",null,"Example with multi-project build: ",Object(c.b)("a",{parentName:"p",href:"https://github.com/thesamet/sbt-protoc/tree/master/examples/scalajs-multiproject"},"https://github.com/thesamet/sbt-protoc/tree/master/examples/scalajs-multiproject")),Object(c.b)("p",null,"Live demo: ",Object(c.b)("a",{parentName:"p",href:"http://thesamet.github.io/scalapbjs-test/"},"http://thesamet.github.io/scalapbjs-test/")))}u.isMDXComponent=!0}}]);