当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript worker-rpc.RpcProvider类代码示例

本文整理汇总了TypeScript中worker-rpc.RpcProvider的典型用法代码示例。如果您正苦于以下问题:TypeScript RpcProvider类的具体用法?TypeScript RpcProvider怎么用?TypeScript RpcProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了RpcProvider类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: RpcProvider

import { RpcProvider } from "worker-rpc";
import * as jsonMap from "json-source-map";

const rpcProvider = new RpcProvider((message: any, transfer: any) => postMessage(message, transfer));

onmessage = e => rpcProvider.dispatch(e.data);

rpcProvider.registerRpcHandler("generateSourceMap", ({ obj }: any) => jsonMap.stringify(obj, null, 2));
开发者ID:amarnus,项目名称:demo-codemirror-json-fold,代码行数:8,代码来源:App.worker.ts

示例2: postMessage

 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License along
 *   with this program; if not, write to the Free Software Foundation, Inc.,
 *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

declare function postMessage(message: any, transfer?: any): void;

import { RpcProviderInterface, RpcProvider } from 'worker-rpc';

let rpcProvider: RpcProvider = null,
    port: MessagePort = null,
    portPending: MessagePort = null;

function send(message: any, transfer?: any): void {
    if (port) {
        port.postMessage(message, transfer);
    } else {
        postMessage(message, transfer);
    }

    if (portPending) {
        port = portPending;
        port.onmessage = (e: MessageEvent) => rpcProvider.dispatch(e.data);
    }
开发者ID:DirtyHairy,项目名称:6502.ts,代码行数:30,代码来源:rpc.ts

示例3:

onmessage = e => rpcProvider.dispatch(e.data);
开发者ID:amarnus,项目名称:demo-codemirror-json-fold,代码行数:1,代码来源:App.worker.ts

示例4:

onmessage = (e: MessageEvent) => port || rpcProvider.dispatch(e.data);
开发者ID:DirtyHairy,项目名称:6502.ts,代码行数:1,代码来源:rpc.ts

示例5:

onmessage = messageEvent => rpcProvider.dispatch(messageEvent.data);
开发者ID:mschroeder,项目名称:6502.ts,代码行数:1,代码来源:main.ts


注:本文中的worker-rpc.RpcProvider类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。