# remote-action-promise

> This library is used to convert a Salesforce VisualForce remote action into a promise. It is written in typescript and allows you to quickly define types for the resulting function.

Latest version **1.0.9** (published 2020-06-04) · ISC license · 0 weekly downloads

## Install

```sh
npm install remote-action-promise
pnpm add remote-action-promise
yarn add remote-action-promise
bun add remote-action-promise
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.9 |
| Published | 2020-06-04 |
| First published | 2020-06-04 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 8.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Maintainers | cjonas |

## Links

- npm: https://www.npmjs.com/package/remote-action-promise
- Repository: https://github.com/ChuckJonas/remote-action-promise
- Homepage: https://github.com/ChuckJonas/remote-action-promise#readme
- Issues: https://github.com/ChuckJonas/remote-action-promise/issues
- npm.io page: https://npm.io/package/remote-action-promise

## Recent versions

- 1.0.9 (latest) — 2020-06-04
- 1.0.8 — 2020-06-04
- 1.0.7 — 2020-06-04
- 1.0.6 — 2020-06-04
- 1.0.5 — 2020-06-04
- 1.0.4 — 2020-06-04
- 1.0.3 — 2020-06-04
- 1.0.2 — 2020-06-04
- 1.0.1 — 2020-06-04
- 1.0.0 — 2020-06-04

## README

# Promisify Salesforce Remote Actions

This library is used to convert a Salesforce VisualForce remote action into a promise.  It is written in typescript and allows you to quickly define types for the resulting function.

## Usage

### Apex Controller

``` java
public class MyController{
  @RemoteAction
  public static String foo(String param1, Integer param2, Boolean param3) {
    return 'hello world';
  }
}
```

### typescript
``` ts
import { promisifyRemoteAction } from 'remote-action-promise';

//this gets injected on the global scope so we need to declare it if using typescript
declare var MyController: {
  foo: any;
};

// this syntax requires Typescript > 4.0
// can use unnamed tuple instead
type FooParams = [param1: string, param2: number, param3: boolean];

const fooRemoteAction = promisifyRemoteAction<FooParams, string>(MyController.foo);

(async() => {

  try{
    const stringResult = await fooRemoteAction('hello', 42, true);
  }catch(e){
    console.log('error', e);
  }

})()

```

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