Skip to content

Instantly share code, notes, and snippets.

View cms's full-sized avatar

Christian C. Salvadó cms

View GitHub Profile
@cms
cms / fetch-timeout.js
Last active June 4, 2019 16:45
fetch with cancellation at timeout using AbortController
export default function fetchWithTimeout(url, options, timeout = 3000) {
const controller = new AbortController()
const { signal } = controller
setTimeout(() => controller.abort(), timeout)
return fetch(url, { ...options, signal })
}
@cms
cms / debounce.js
Created July 24, 2019 19:14
Small debounce function
/**
* Small debounce function.
*
* by Christian C. Salvadó <[email protected]>
* MIT Style license, 2019
*/
function debounce(fn, ms = 0) {
let timer = 0
@cms
cms / getCurrentPosition.js
Created August 13, 2019 18:08
navigator.geolocation.getCurrentPosition promise
function getCurrentPosition(options) {
return new Promise(function(resolve, reject) {
navigator.geolocation.getCurrentPosition(resolve, reject, options);
});
}
(async () => {
const position = await getCurrentPosition().catch(err => console.log(err));
console.log(position);
})();
import _ from "lodash";
import React from 'react';
import moment from 'moment';
import { connect } from 'react-redux';
import API from '@Services/Api/profile';
import { ApiManager } from "../../api/apiManager";
import ParsedText from 'react-native-parsed-text';
import { NavigationEvents } from "react-navigation";
import { DateToWordsFromNow } from '../../helpers/helper';
import { ACTIVITY_NOTIFICATION } from "../../api/constants";
@cms
cms / Optimizar.js
Last active January 10, 2020 14:55
import _ from "lodash"
import React from "react"
import moment from "moment"
import { connect } from "react-redux"
import API from "@Services/Api/profile"
import { ApiManager } from "../../api/apiManager"
import ParsedText from "react-native-parsed-text"
import { NavigationEvents } from "react-navigation"
import { DateToWordsFromNow } from "../../helpers/helper"
import { ACTIVITY_NOTIFICATION } from "../../api/constants"