This file contains hidden or 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
export async function addVehicle(userId, vehicle) { | |
return api.addVehicle(userId, vehicle, axios).then(data => { | |
if (!data.errors) { | |
store.dispatch({ | |
type: types.ADD_VEHICLE, | |
vehicle: data.data.addVehicle | |
}); | |
return data; | |
} | |
return Promise.reject(data.errors); |
This file contains hidden or 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
<?php | |
class User { | |
private $name; | |
private $age; | |
public function setName(string $name) { | |
$this->name = $name; | |
} | |
public function setAge($age):void |
This file contains hidden or 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
if (expresion) { | |
return true; | |
} else { | |
return false; | |
} | |
// which can be refactored to | |
return expresion; |
This file contains hidden or 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
function validateEmail(email) { | |
// validate and return true or false | |
} | |
function isEmailValid(email) { | |
// validate and return true or false | |
} | |
function emailIsValid(email) { | |
// validate and return true or false |
This file contains hidden or 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
<?php | |
class WidgetList { | |
public int numberOfWidgets () {...} | |
} |
This file contains hidden or 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
/*********************************************************** | |
* Some fancy comments here * | |
* * | |
***********************************************************/ |
This file contains hidden or 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
export default { | |
name: 'some-component', | |
data () { | |
return { | |
name: 'sadick' | |
} | |
}, | |
methods: { | |
getUsername () { | |
this.$store.dispatch('getUsernameFromAPI') |
This file contains hidden or 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
//get all shops | |
const shops = await this.$store.dispatch('get', { | |
url: '/shops', | |
params: { | |
type: 'all' | |
}, | |
type: 'GET_SHOPS_SUCCESS' | |
}) | |
// use your response if you need to |
This file contains hidden or 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
export const get = ({commit}, {url = '', params = {}, type = '', canCommit = true}) => { | |
axios.get(url, { | |
params | |
}).then(resp => { | |
if (canCommit) { | |
commit(type, resp.data) | |
} | |
return resp.data | |
}) | |
} |
This file contains hidden or 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
export const get = ({commit}, {url = '', params = {}}) => { | |
axios.get(url, { | |
params | |
}).then(resp => { | |
return resp.data | |
}) | |
} |