Skip to content

Store is not defined #13

@smartITNinja

Description

@smartITNinja

Expected Behavior

Loading beedle from unpkg.com CDN directly on browser

Actual Behavior

This error is reported: Uncaught ReferenceError: Store is not defined

Steps to Reproduce the Problem

<script src="//unpkg.com/beedle"></script>
<textarea></textarea> <script> const actions = { saySomething(context, payload) { context.commit('setMessage', payload); } }; const mutations = { setMessage(state, payload) { state.message = payload; return state; } }; const initialState = { message: 'Hello, world' }; const storeInstance = new Store({ actions, mutations, initialState }); const textElement = document.querySelector('textarea'); textElement.addEventListener('input', () => { // Dispatch the action, which will subsequently pass this message to the mutation // which in turn, updates the store's state storeInstance.dispatch('saySomething', textElement.value.trim()); }); // Grab the text element and attach it to the stateChange event const messageElement = document.querySelector('.js-message-element'); // This fires every time the state updates storeInstance.subscribe(state => { messageElement.innerText = state.message; }); </script>

My Browser link(s)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions