# react-native-onupdate

> A module which you can register some onupdate functions for already released versions for your app. Kind of like migrations in a database.

Latest version **1.0.2** (published 2020-11-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-native-onupdate
pnpm add react-native-onupdate
yarn add react-native-onupdate
bun add react-native-onupdate
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2020-11-12 |
| First published | 2020-11-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | tolgaberk |
| Maintainers | tolgaberk |
| Keywords | migration, update, react-native, onupdate |

## Links

- npm: https://www.npmjs.com/package/react-native-onupdate
- Repository: https://github.com/tolgaberk/react-native-onupdate
- Homepage: https://github.com/tolgaberk/react-native-onupdate#readme
- Issues: https://github.com/tolgaberk/react-native-onupdate/issues
- npm.io page: https://npm.io/package/react-native-onupdate

## Recent versions

- 1.0.2 (latest) — 2020-11-12
- 1.0.1 — 2020-11-10
- 1.0.0 — 2020-11-10

## README

# Get migration like logic for your released App

Keep track of which functions have been called when releasing a new update!

# Installation

`yarn add react-native-onupdate @react-native-async-storage/async-storage && npx pod-install`

## or

`npm i react-native-onupdate @react-native-async-storage/async-storage && npx pod-install`

# Usage

```
import OnUpdate from 'react-native-onupdate';

const migrationFunctions = [
    () => { console.log('migration 1') },
    () => { console.log('migration 2') },
    () => { console.log('migration 3') }
];

OnUpdate.migrations = migrationFunctions;

const App = () => {
    OnUpdate.migrate();

    return (
        <View>
            <Text>TEST</Text>
        </View>
    );
}
```

# API

| Property \| Method   | DEFINITION                                                            | TYPE                           |
| -------------------- | --------------------------------------------------------------------- | ------------------------------ |
| `migrations`         | Migration functions to run                                            | `Function[]`                   |
| `migrate()`          | Runs the migrations which have been never called                      | `function()`                   |
| `DEBUG(true\|false)` | Enables logging                                                       | `function(debug:boolean):void` |
| `version`            | Last runned migration functions index. It persists in `AsyncStorage`. | `number`                       |
| `AsyncStorageKey`    | The key used for `AsyncStorage`                                       | `string`                       |

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