# rbx-remoteevent

> Typed Remote Event support for roblox-ts.

Latest version **1.0.1** (published 2019-05-28) · ISC license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install rbx-remoteevent
pnpm add rbx-remoteevent
yarn add rbx-remoteevent
bun add rbx-remoteevent
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2019-05-28 |
| First published | 2019-05-28 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 52.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | karikera |
| Maintainers | karikera |
| Keywords | roblox-ts, roblox, remoteevent |

## Links

- npm: https://www.npmjs.com/package/rbx-remoteevent
- Repository: https://github.com/karikera/rbx-remoteevent
- Homepage: https://github.com/karikera/rbx-remoteevent#readme
- Issues: https://github.com/karikera/rbx-remoteevent/issues
- npm.io page: https://npm.io/package/rbx-remoteevent

## Alternatives

- [async-exit-hook](https://npm.io/package/async-exit-hook.md) — 3.7M weekly downloads
- [evnty](https://npm.io/package/evnty.md) — 7.2K weekly downloads
- [eleventy-plugin-asciidoc](https://npm.io/package/eleventy-plugin-asciidoc.md) — 3.5K weekly downloads
- [@jswork/next-get2get](https://npm.io/package/@jswork/next-get2get.md) — 945 weekly downloads
- [@dashersw/axon](https://npm.io/package/@dashersw/axon.md) — 934 weekly downloads

## Recent versions

- 1.0.1 (latest) — 2019-05-28
- 1.0.0 — 2019-05-28

## README

# Definations TO Implements!
![Definations TO Implements!](readme-image/first.png)

# Reference

## createServerRemoteEvents Function
Parameter - `args:{client:FunctionObjects, server:FunctionObjects}`  
Remote Event Definations

Convert remote event Definations to functions.  
Definations are needed to define with empty functions.  
It will creates `RemoteEvent` to `ReplicatedStorage/rbx-remoteevent/*`.  
client functions will be [ServerRemoteSender](#methods-of-serverremotesender-class) class objects.  
server functions will be `OnClientEvent:Connection` functions.  

## createClientRemoteEvents Function
**This is a yielding function.**  
It will **WAITS** `RemoteEvent` creating of `createServerRemoteEvents`.  

Parameter - `args: {client:FunctionObjects, server:FunctionObjects}`  
Remote events Definations

Simmilar with `createServerRemoteEvents` but for client.  
client functions will be `FireServer` functions.
server functions will be `OnServerEvent:Connection` functions.

## Methods of ServerRemoteSender Class
* `fire(client, ...)` - send to one client  
* `fireAll(...)` - send to all clients  
* `fireWithout(client, ...)` - send to all without specific client  
* `fires(clientArray, ...)` - send to partial clients  

# Example
## common.ts
```typescript

// Define Remote Event Reference
export const remoteEventsReference = {
    client:{ // Server to Client
        youAre(a:number, b:string, c:boolean, name:string){},
        someoneJoined(a: number, b:string, c:boolean, name:string){},
    },
    server:{ // Client to Server
        whoAmI(a:number, b:string, c:boolean){}
    }
};

```

## client.ts
```typescript
import { createClientRemoteEvents } from "rbx-remoteevent";
import { remoteEventsReference } from "./common";

const remoteEvent = createClientRemoteEvents(remoteEventsReference);


// Receive from Server
remoteEvent.client.youAre((a, b, c, name)=>{
    print(`I'm ${name} (${a}, ${b}, ${tostring(c)})`);
});

// Send to Server
remoteEvent.server.whoAmI(math.random(), 'string', true);

```

## server.ts
```typescript
import { createServerRemoteEvents } from "rbx-remoteevent";
import { remoteEventsReference } from "./common";

const remoteEvent = createServerRemoteEvents(remoteEventsReference);


// Receive from Client
remoteEvent.server.whoAmI((player, a, b, c)=>{

    // Send to 'player'
    remoteEvent.client.youAre.fire(player, a, b, c, player.Name);

    // Send to All
    remoteEvent.client.someoneJoined.fireAll(a, b, c, player.Name);

    // Send to partial players
    const [p1, p2, p3] = game.GetService('Players').GetChildren();
    remoteEvent.client.someoneJoined.fires([p1, p2, p3], a, b, c, player.Name);

    // Send to All without 'player'
    remoteEvent.client.someoneJoined.fireWithout(player, a, b, c, player.Name);
});
```

---
_Source: https://npm.io/package/rbx-remoteevent · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
