Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// {
// id: 1,
// title: 'Post 1',
// text: 'Post 1 text',
// img: 'https://picsum.photos/200/200/?image=977'
// },
// {
// id: 2,
// title: 'Post 2',
// text: 'Post 2 text',
// img: 'https://picsum.photos/200/200/?image=1'
// }
// ]
};
const state = remx.state(initialState);
const getters = remx.getters({
getPosts() {
return state.posts;
},
getPost(id) {
const post = _find(state.posts, {id})
return post;
}
});
const setters = remx.setters({
setPosts(posts) {
state.posts = posts;
},
import _ from 'lodash';
import * as remx from 'remx';
const MAX_TOPICS_SELECTED = 3;
const state = remx.state({
loading: true,
topicsByUrl: {},
selectedTopicUrls: [],
finishedTopicsSelection: false
});
export const setters = remx.setters({
setTopics(topics) {
state.topicsByUrl = _.keyBy(topics, (t) => t.url);
state.loading = false;
},
toggleTopic(topicUrl) {
if (getters.isTopicSelected(topicUrl)) {
state.selectedTopicUrls = _.without(state.selectedTopicUrls, topicUrl);
} else {
import * as remx from 'remx';
const state = remx.state({
myItems: ['nacho', 'burrito', 'hotdog']
});
const setters = remx.setters({
setNewItemText(txt) {
state.newItemText = txt;
},
addItem() {
state.myItems = state.myItems.concat(getters.getNewItemText());
state.newItemText = '';
},
clear() {
state.myItems = [];
}
const remx = require('remx');
const state = remx.state({
person: {
name: 'no name'
}
});
const setters = remx.setters({
setName(newName) {
state.person.name = newName;
},
setAge(age) {
state.person.age = age;
}
});
const getters = remx.getters({
import _ from 'lodash';
import * as remx from 'remx';
const state = remx.state({
loading: true,
postsById: {},
selectedPostId: '',
currentFilter: 'all'
});
export const setters = remx.setters({
setPosts(posts) {
state.postsById = _.keyBy(posts, (p) => p.id);
state.loading = false;
},
selectPost(postId) {
state.selectedPostId = postId;
},