Skip to content

Instantly share code, notes, and snippets.

@rsyring
Created November 20, 2017 04:44
Show Gist options
  • Save rsyring/fbb54bb2f4b5bdf6cce892ee6a8fae32 to your computer and use it in GitHub Desktop.
Save rsyring/fbb54bb2f4b5bdf6cce892ee6a8fae32 to your computer and use it in GitHub Desktop.
Mithril Contacts
function Contacts(vn) {
let contacts = [
{name: 'Fred', email: '[email protected]'},
{name: 'Bob', email: '[email protected]'},
]
function addContact(contact) {
contacts.push(contact)
}
function delContact(email) {
// PROBLEM HERE
contacts = contacts.filter((el) => el.email !== email);
}
return {
view: function() {
return m("main", [
m(ContactForm, {addContact: addContact}),
m(ContactList, {contacts: contacts, delContact: delContact}),
])
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment