Skip to content

Instantly share code, notes, and snippets.

@billmalarky
billmalarky / final-app-js-for-background-tasks
Created January 5, 2018 23:09
Final App.js file for background task and queue integration.
import React, { Component } from 'react';
import {
Platform,
StyleSheet,
Text,
ScrollView,
Button,
Image
} from 'react-native';
import React, { Component } from 'react';
import {
Platform,
StyleSheet,
Text,
ScrollView,
Button,
Image
} from 'react-native';
@billmalarky
billmalarky / component-did-mount-snippet.js
Created January 5, 2018 21:09
Easy OS Background Tasks in React Native - componentDidMount() snippet.
componentDidMount() {
BackgroundTask.schedule(); // Schedule the task to run every ~15 min if app is closed.
}
@billmalarky
billmalarky / background-task-code-snippet.js
Last active January 5, 2018 21:18
background task snippet
import BackgroundTask from 'react-native-background-task'
import queueFactory from 'react-native-queue';
BackgroundTask.define(async () => {
// Init queue
queue = await queueFactory();
// Register job worker
queue.addWorker('pre-fetch-image', async (id, payload) => {
@billmalarky
billmalarky / two-screen-app-js.js
Created January 5, 2018 20:57
Basic app.js with two screens.
import React, { Component } from 'react';
import {
Platform,
StyleSheet,
Text,
ScrollView,
Button,
Image
} from 'react-native';
@billmalarky
billmalarky / react-native-queue-integration-with-react-native-workers.js
Created January 5, 2018 02:18
React Native Queue integration with react-native-workers
// https://github.com/billmalarky/react-native-queue
// https://github.com/devfd/react-native-workers
// ######################
// From your application:
// ######################
import queueFactory from 'react-native-queue';
import { Worker } from 'react-native-workers';
// Initialize queue and throw a few jobs on it