Skip to content

Commit

Permalink
fix(readme): fixed formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewcourtice committed Oct 7, 2020
1 parent 8286909 commit fe4cc78
Showing 1 changed file with 42 additions and 35 deletions.
77 changes: 42 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,16 @@ const {
} = createStore('user', STATE);

export const state = store.state;

export const fullName = getter('fullname', state => `${state.firstName} ${state.lastName}`);
export const setFirstName = mutation('set-first-name', (state, payload) => state.firstName = payload || '');
export const setLastName = mutation('set-last-name', (state, payload) => state.lastName = payload || '');

export const setFirstName = mutation('set-first-name', (state, payload) => {
state.firstName = payload || '';
});

export const setLastName = mutation('set-last-name', (state, payload) => {
state.lastName = payload || '';
});
```

4. Use your store in your app:
Expand All @@ -94,39 +101,39 @@ export const setLastName = mutation('set-last-name', (state, payload) => state.l
</template>

<script lang="ts">
import {
defineComponent,
computed
} from 'vue';
import {
state,
fullName,
setFirstName,
setLastName
} from './stores/user';
export default defineComponent({
setup() {
const firstName = computed({
get: () => state.firstName,
set: setFirstName
});
const lastName = computed({
get: () => state.lastName,
set: setLastName
});
return {
firstName,
lastName,
fullName
};
}
});
import {
defineComponent,
computed
} from 'vue';
import {
state,
fullName,
setFirstName,
setLastName
} from './stores/user';
export default defineComponent({
setup() {
const firstName = computed({
get: () => state.firstName,
set: setFirstName
});
const lastName = computed({
get: () => state.lastName,
set: setLastName
});
return {
firstName,
lastName,
fullName
};
}
});
</script>
```

Expand Down

0 comments on commit fe4cc78

Please sign in to comment.