location.js 664 Bytes
import {
  SOLICITUD_POSTED,
} from '../actions/solicitudes'

import {
  requestLocation,
  requestLocationPermission,
  postLocation,
  LOCATION_PERMISSION_GRANTED,
  LOCATION_RECEIVED
} from '../actions/location'

export const askLocationOnPost = (action$) =>
  action$.ofType(SOLICITUD_POSTED)
    .map(action => requestLocationPermission(action.solicitud))

export const getLocationOnGrant = (action$) =>
  action$.ofType(LOCATION_PERMISSION_GRANTED)
    .map(action => requestLocation(action.solicitud))

export const postLocationOnReceive = (action$) =>
  action$.ofType(LOCATION_RECEIVED)
    .map(action => postLocation(action.location, action.solicitud))