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
const reducer = (state, action) => { | |
if (action.type === 'ADD_TODO') { | |
return { ...state, todo: [...state.todo, action.payload] }; | |
} else { | |
return state; | |
} | |
}; |
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
const state = {}; | |
const subscribe = (listener) => { | |
listeners.push(listener); | |
}; | |
const dispatch = (action/change) => { | |
const newState = getNewState(state, action); | |
state = newState; | |
}; |
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
const action = { type: 'ADD_TODO', payload: 'Have a snack' }; |
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
const state = {}; | |
const listeners = []; | |
const subscribe = (listener) => { | |
listeners.push(listener); | |
}; | |
const dispatch = (action/change) => { | |
const newState = getNewState(state, action); | |
state = newState; |
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
const state = {}; |
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
const REDIRECT_URL = CONFIG.serverRedirectURL; | |
const isDomainValid = (item) => item.detatils.valid; | |
const getProtocol = (item) => (isDomainValid(item) ? 'https' : 'http'); | |
const getDomainName = (item) => item.details.name; | |
const getUrl = (item) => `${getProtocol(item)}://${getDomainName(item)}?}`; | |
// TODO: (temporary) Adding callback=true because server side redirection needs this parameter | |
const addCallbackParameter = (url) => `${url}&callback=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
const getDomainName = (item) => item.details.name; | |
const getProtocol = (item) => (item.details.valid ? 'https' : 'http'); | |
const getUrl = (item) => `${getProtocol(item)}://${getDomainName(item)}`; | |
// TODO: (temporary) Adding callback=true because server side redirection needs this parameter | |
const addCallbackParameter = (url) => `${url}?callback=true`; | |
const generateUrl = (item) => { | |
const url = getUrl(item); | |
const urlWithCallbackParameter = addCallbackParameter(url); | |
return urlWithCallbackParameter; |
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
const getDomainName = (item) => item.details.name; | |
const getProtocol = (item) => (item.details.valid ? 'https' : 'http'); | |
const getUrl = (item) => `${getProtocol(item)}://${getDomainName(item)}`; | |
// TODO: (temporary) Adding callback=true because server side redirection needs this parameter | |
const addCallbackParameter = (url) => `${url}?callback=true`; | |
const urlList = domainList.map(getUrl).map(addCallbackParameter); |
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
const getDomainName = (item) => item.details.name; | |
const getProtocol = (item) => (item.details.valid ? 'https' : 'http'); | |
const getUrl = (item) => `${getProtocol(item)}://${getDomainName(item)}`; | |
// TODO: (temporary) Adding callback=true because server side redirection needs this parameter | |
const addCallbackParameter = (url) => `${url}?callback=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
// Construct URL list | |
// Adding https protocol since the backend service doesn't accept http | |
// TODO: (temporary) Adding callback=true because server side redirection needs this parameter | |
const urlList = domainList.map((item) => { | |
const domain = item.details.name; | |
let url; | |
if (item.details.valid) { | |
url = `https://${domain}?callback=true`; | |
} else { | |
url = `http://${domain}?callback=true`; |
NewerOlder