Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V2 - modular accessors #297

Open
dxinteractive opened this issue Apr 29, 2020 · 0 comments
Open

V2 - modular accessors #297

dxinteractive opened this issue Apr 29, 2020 · 0 comments

Comments

@dxinteractive
Copy link
Collaborator

dxinteractive commented Apr 29, 2020

Split out type-based parcel methods and actions so adding support for new data types is modular.
Also remove as much unmutable as possible from the core library

export const array = (parcel) => ({
    when: Array.isArray(parcel.value),
    getters: {
        isIndexed: () => true
    },
    methods: {
        push: (...values) => ['push', values],
        pop: () => parcel.get(-1).delete()
    },
    actions: {
        push: (data, values) => data.concat(values) // how to handle child?
    }
});

export const arrayChild = (parcel) => ({
    when: Array.isArray(parcel._parent),
    always: true,
    child: true,
    getters: {
        isElement: () => true,
        isFirstChild: () => {},
        isOnlyChild: () => {}
    },
    methods: {
        swapNext: () => ['swapNext']
    },
    actions: {
        swapNext: (data, lastKey, values) => { ... }
    }
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant