This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Feeds model before cache | |
import DB from '../db'; | |
const FeedModel = { | |
getUserFeeds(userID) { | |
const selectQuery = `SELECT * FROM feeds WHERE userID = ${userID}`; | |
return DB.then((connection) => |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import NodeCache from 'node-cache'; | |
class Cache { | |
constructor(ttlSeconds) { | |
this.cache = new NodeCache({ stdTTL: ttlSeconds, checkperiod: ttlSeconds * 0.2, useClones: false }); | |
} | |
get(key, storeFunction) { | |
const value = this.cache.get(key); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Initializing cache service in feeds model | |
import DB from '../db'; | |
import CacheService from '../cache.service'; | |
const ttl = 60 * 60 * 1; // cache for 1 Hour | |
const cache = new CacheService(ttl); // Create a new cache service instance | |
const FeedModel = { | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Feeds model after cache | |
import DB from '../db'; | |
import CacheService from '../cache.service'; | |
const ttl = 60 * 60 * 1; // cache for 1 Hour | |
const cache = new CacheService(ttl); // Create a new cache service instance | |
const FeedModel = { | |
// ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Feeds model after cache | |
import DB from '../db'; | |
import CacheService from '../cache.service'; | |
const ttl = 60 * 60 * 1; // cache for 1 Hour | |
const cache = new CacheService(ttl); // Create a new cache service instance | |
const FeedModel = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// en.json | |
{ | |
"login": { | |
"welcome": "Welcome {{name}} to our localized app!", | |
"login_button": "Login", | |
"signup_button": "Sign Up" | |
}, | |
"user_profile": { | |
"title": "Your Profile" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// he.json | |
{ | |
"login": { | |
"welcome": "{{name}}, ברוך הבא לאפליקציה המתורגמת!", | |
"login_button": "התחבר", | |
"signup_button": "הרשם" | |
}, | |
"user_profile": { | |
"title": "הפרופיל שלך" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ReactNative from 'react-native'; | |
import I18n from 'react-native-i18n'; | |
// Import all locales | |
import en from './en.json'; | |
import he from './he.json'; | |
// Should the app fallback to English if user locale doesn't exists | |
I18n.fallbacks = true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import { | |
View, | |
Text, | |
Button | |
} from 'react-native'; | |
class LoginScreen extends Component { | |
constructor(props) { | |
super(props); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import { | |
View, | |
Text, | |
Button | |
} from 'react-native'; | |
import { strings } from '../locales/i18n'; | |
class LoginScreen extends Component { |
OlderNewer