Skip to content

Instantly share code, notes, and snippets.

@rsyring
Created November 20, 2017 04:44
Show Gist options
  • Select an option

  • Save rsyring/fbb54bb2f4b5bdf6cce892ee6a8fae32 to your computer and use it in GitHub Desktop.

Select an option

Save rsyring/fbb54bb2f4b5bdf6cce892ee6a8fae32 to your computer and use it in GitHub Desktop.

Revisions

  1. rsyring created this gist Nov 20, 2017.
    24 changes: 24 additions & 0 deletions example.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    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}),
    ])
    }
    }
    }