xi

toxin alert

Today on Toothpaste For Dinner: toxin alert








xi

How to Prevent Your Pet From Developing Separation Anxiety Post Quarantine

During this crazy time many of us have been confined to our homes and for some that means to be home 24/7 with our best friends. Our pets. However, because of this, many pets have become accustomed to having us home with them. 

But then the question is... will they be okay once bans are lifted and people are able to slowly go back to their daily routines?

Will they be able to handle their best friends not being by their side 24/7?

It is expected that many dogs (even cats!) can suffer from separation anxiety, and pet experts are saying that it's a good idea to get your pet ready and used to post-quarantine separation now, to minimize their stress later. 

Here are some useful tips for both dog and cat owners.

More videos on Cheezburger's Youtube Channel 





xi

Ripples in Earth’s atmosphere make distant galaxies appear to flash

Faraway galaxies have been spotted unexpectedly flashing up to 100 times their usual brightness, and it seems to be caused by eddies in Earth’s atmosphere




xi

Electrical devices implanted in the brain may help treat anorexia

In a small trial, implanting electrodes into the brain helped women with severe anorexia gain weight and feel less anxious and depressed




xi

3 nurses strangled in Mexico; border mayor gets coronavirus

Three sisters who worked in Mexico's government hospital system were found murdered by strangling, authorities in the northern border state of Coahuila announced Friday, stirring new alarm in a country where attacks on health care workers have occurred across the nation amid the coronavirus outbreak. Two of the sisters were nurses for the Mexican Social Security Institute and the third was a hospital administrator, but there was no immediate evidence the attack was related to their work. The National Union of Social Security Employees called the killings “outrageous and incomprehensible.”





xi

Brexit: Simon Coveney says trade talks progress not good

The Irish deputy PM says time is short to reach a trade deal this year, with much still to do.




xi

Met Police end probe into pro-Brexit campaigners

Leave campaigners were accused by the Electoral Commission of breaking the law over spending limits.




xi

Can robotaxis ease public transport fears in China?

More self-driving cabs are being launched in China at a time when people are worried about public transport.




xi

Coronavirus: ‘It’s just anxiety, anxiety, anxiety’

The coronavirus crisis is having a huge impact on young people with existing mental health conditions.




xi

Staging a 'socially distanced' boxing match

Inside the Nicaraguan boxing event that caught the world's attention during the pandemic.




xi

Mexico receives ventilator shipment from US

The 211 machines were purchased from a US firm, Mexico's foreign minister said.




xi

Life for asylum seekers in lockdown on the US-Mexico border

Magaly Contreras has spent nine months in a Tijuana shelter and is worried about her future.




xi

Using Proxies with Redux Types

One of the most common problems that I run into when using Redux is trying to figure out why an action is not being captured by a reducer. For someone just getting starting with Redux, debugging this issue can be especially overwhelming because of how Redux manages data flow. So before you start pouring over configuration code, or the logic contained in your action creators and reducers, please, make sure your action types are defined and spelled correctly.

One of the most common problems that I run into when using Redux is trying to figure out why an action is not being captured by a reducer. For someone just getting starting with Redux, debugging this issue can be especially overwhelming because of how Redux manages data flow. So before you start pouring over configuration code, or the logic contained in your action creators and reducers, please, make sure your action types are defined and spelled correctly.

In any application that I have built, most bugs that I have run into are simply due to typos. However, the solution to this particular problem is harder to spot because no errors are raised when the application is run. Take a look at the snippet below.

// actionTypes.js

export const FETCH_FILE_REQUEST = 'fetch_file_request';
export const FETCH_FILE_SUCCESS = 'fetch_file_success';
export const FETCH_FILE_FAIL = 'fetch_file_fail';


// filesReducer.js

import {
  FETCH_FILE_REQUEST,
  FETCH_FILE_SUCESS,
  FETCH_FILE_FAIL
} from '../actions/actionTypes';

const filesReducer = (state = {}, action) => {
  switch (action.type) {
    case FETCH_FILE_SUCESS:
      return { ...state, file: action.payload };
    default:
      return state;
  }
}

export default filesReducer;

Assuming we dispatched an action with type FETCH_FILE_SUCCESS, the filesReducer should catch the action before the default case is returned. But what if that is not happening? Where do we start the debugging process. There does not appear to be anything wrong with the code in the reducer; the action type was imported and matches the case in the switch statement. There are no errors in the browser. Where is the issue?

You may have noticed that I misspelled SUCCESS in filesReducer.js, but the reason this can be hard to catch is because importing undefined types does not cause an error, so when we import FETCH_FILE_SUCESS, its value is actually undefined, so our reducer always hits the default case.

It would be nice if the existing import/export system could help us catch this. Unfortunately, since action types are just strings, validating their existence is challenging. Luckily, we have another option.

Enter Proxies

Proxies are a feature of ES2015 that allow us to customize operations on a object. They can be used in many different ways, and you can find some useful examples here and here. For our problem, this example from Mozilla looks promising:

let validator = {
  set: function(obj, prop, value) {
    if (prop === 'age') {
      if (!Number.isInteger(value)) {
        throw new TypeError('The age is not an integer');
      }
      if (value > 200) {
        throw new RangeError('The age seems invalid');
      }
    }

    // The default behavior to store the value
    obj[prop] = value;

    // Indicate success
    return true;
  }
};

let person = new Proxy({}, validator);

person.age = 100;
console.log(person.age); // 100
person.age = 'young'; // Throws an exception
person.age = 300; // Throws an exception

So if proxies can be used to validate that properties assigned to an object are of a certain type and value, we should definitely be able to ensure that our action types are never undefined, or else throw an error that will be easy for us to fix. Let’s refactor our actionTypes.js file.

// actionTypes.js

const types = {
  FETCH_FILE_REQUEST: 'fetch_file_request',
  FETCH_FILE_SUCCESS: 'fetch_file_success',
  FETCH_FILE_FAIL: 'fetch_file_fail'
}

const typeValidator = {
  get(obj, prop) {
    if (obj[prop]) {
      return prop;
    } else {
      throw new TypeError(`${prop} is not a valid action type`);
    }
  }
}

module.exports = new Proxy(types, typeValidator);

First, we define a object containing all our action types. Then we define our validator handler typeValidator. The get method inside our handler is called a trap, and provides access to the properties of a object. If the property we are looking for, an action type, in this case, exists in the types object, return that prop, unmodified. Otherwise, throw an error because the prop does not exist.

Finally, export a new proxy, passing the types object as the target and the typeValidator as the handler. However, it is important to note that the ES2015 module system does not work well with proxies, so module.exports and require() must be used for exporting and importing the types.

Barely any code needs to change in the reducer and action creator files, but in order for the action types to be imported successfully, we just need couple lines of code in a new file:

// actionTypesProxy.js

export const {
  FETCH_FILE_REQUEST,
  FETCH_FILE_SUCCESS,
  FETCH_FILE_FAIL,
} = require('./actionTypes');

// in the reducer and action creator files
// change '../actions/actionTypes' to
// '../actions/actionTypesProxy'

By creating a proxy to verify the existence of an action type, we no longer have to worry about correctly naming a property upon import because an error will be thrown in the browser console as soon as the application starts. So, reduce the number headaches you get when developing an application using Redux and start using proxies.

Interested in learning how to build applications using Redux with ReactJS. Check out this online course! Modern React with Redux




xi

Mission XI Million milestone children at the Jawaharlal Nehru Stadium in New Delhi

Mission XI Million milestone children at the Jawaharlal Nehru Stadium in New Delhi.




xi

Filipe Luis: We're giving the semi-final maximum priority




xi

Ricardinho (R) of Portugal plays the ball past Maximiliano Rescia (L) of Argentina

Ricardinho (R) of Portugal plays the ball past Maximiliano Rescia (L) of Argentina during the FIFA Futsal World Cup Semi-Final match between Argentina and Portugal at the Coliseo El Pueblo stadium on September 28, 2016 in Cali, Colombia. (Photo by Alex Caparros - FIFA/FIFA via Getty Images)




xi

Maximilano Rescia of Argentina celebrates after he scores

Maximilano Rescia of Argentina celebrates after he scores during the FIFA Futsal World Cup Final match between Russia and Argentina at the Coliseo el Pueblo Stadiumon October 1, 2016 in Cali, Colombia. (Photo by Ian MacNicol - FIFA/FIFA via Getty Images)




xi

Maximilano Rescia of Argentina celebrates after he scores

CALI, COLOMBIA - OCTOBER 01: Maximilano Rescia of Argentina celebrates after he scores during the FIFA Futsal World Cup Final match between Russia and Argentina at the Coliseo el Pueblo Stadiumon October 1, 2016 in Cali, Colombia. (Photo by Ian MacNicol - FIFA/FIFA via Getty Images)




xi

Maximilano Rescia of Argentina celebrates after he scores

CALI, COLOMBIA - OCTOBER 01: Maximilano Rescia of Argentina celebrates after he scores during the FIFA Futsal World Cup Final match between Russia and Argentina at the Coliseo el Pueblo Stadiumon October 1, 2016 in Cali, Colombia. (Photo by Ian MacNicol - FIFA/FIFA via Getty Images)




xi

Tahiti bounce back with dominant win over Mexico




xi

Paraguay's pride and pain after early exit








xi

Rhian Brewster (ENG) v Mexico

Vote for your favourite goal from the FIFA U17 World Cup India 2017 at FIFA.com. Is it this free-kick from England's Rhian Brewster?  




xi

CLASSICO FLASHBACK: Mexico top USA in 1999

Mexican legend Cuauhtémoc Blanco finally beat in-form American goalkeeper Kasey Keller in extra time as the old rivals met in the semi-finals of the FIFA Confederations Cup Mexico 1999. 




xi

Osorio expects dynamic Mexico in Russia

El Tri coach Juan Carlos Osorio talks about the expectations and preparations for the CONCACAF champions ahead of the FIFA Confederations Cup Russia 2017.




xi

34 DAYS TO GO! Mexican Goal-Machine Chicharito

Within 34 minutes of Javier Hernandez’s bow at the FIFA Confederations Cup the striker known as Chicharito had already opened his account, scoring for Mexico against Italy in 2013.





xi

Portugal v Mexico, 2006 FIFA World Cup

Portugal and Mexico faced off in the group stage of the 2006 FIFA World Cup. Goals from Maniche and Simão helped Portugal top the group.




xi

Portugal 2-2 Mexico (Russia 2017)

Watch highlights of the match between Portugal and Mexico from the FIFA Confederations Cup 2017 in Russia.




xi

Cristiano Ronaldo: Budweiser Man of the Match, Portugal v Mexico (Portuguese)

Hear from Cristiano Ronaldo: Budweiser Man of the Match, Portugal v Mexico (Portuguese)




xi

Mexico v New Zealand - Promo - FIFA Confederations Cup 2017

Promo previewing match 6 of the FIFA Confederations Cup 2017 - Mexico v New Zealand




xi

Mexico 2-1 New Zealand (Russia 2017)

Watch highlights of the match between Mexico and New Zealand from the FIFA Confederations Cup 2017 in Russia.




xi

Javier Aquino: Budweiser Man of the Match - Mexico v New Zealand

Hear from FIFA man of the match Javier Aquino after his sides 2-1 win over New Zealand.




xi

Alexis Sanchez: FIFA Man of the Match - Match 8: Germany v Chile

Hear from FIFA man of the match Alexis Sanchez after his sides 1-1 draw with Germany at the FIFA Confederations Cup 2017.




xi

Mexico v Russia - Promo - FIFA Confederations Cup 2017

Promo previewing match 9 of the FIFA Confederations Cup 2017 - Mexico v Russia




xi

Mexico 2-1 Russia (Russia 2017)

Watch highlights of the match between Mexico and Russia from the FIFA Confederations Cup 2017 in Russia.




xi

Germany v Mexico - Promo - FIFA Confederations Cup 2017

Match 14: Germany v Mexico - Promo - FIFA Confederations Cup 2017




xi

Germany v Mexico (2005 FIFA Confederations Cup)

Watch highlights of the dramatic contest between Germany and Mexico at the 2005 FIFA Confederations Cup. Extra time was needed to separate the sides, during which a Michael Ballack goal secured victory for the Germans.




xi

Germany 4-1 Mexico (Russia 2017)

Watch highlights of the semi-final between Germany and Mexico at the FIFA Confederations Cup 2017 in Russia.




xi

Leon Goretzka: Budweiser Man of the Match, Germany v Mexico

Hear from Budweiser Man of the Match Leon Goretzka after his side beat Mexico to reach the Final of the FIFA Confederations Cup 2017.




xi

Match 15: Portugal v Mexico - Promo - FIFA Confederations Cup 2017

Promo previewing match 15 of the FIFA Confederations Cup 2017 - the match for third place between Portugal and Mexico.




xi

Match 15: Portugal v Mexico -Team Lineups - FIFA Confederations Cup 2017

The Lineups for Match 15 of the FIFA Confederations Cup 2017 - Portugal v Mexico