A
A
Artur Galyaev2020-11-15 16:57:01
css
Artur Galyaev, 2020-11-15 16:57:01

Access getter only after request?

I have a component that outputs different values ​​from the state, the data comes to the state from the back.

getDays(state) {
                return state.rtb.days
    	},
    	getQuarter(state) {
    		return state.rtb.weeks.map(item => ({
    			label: item.label,	
    		}))
    	},
    	weeks(state, getters) {
    		switch(state.settings.viewType) {
        case 'daysOfMonth': {
          return getters.getDays
        }
        case 'monthsOfQuarter': {
          return getters.getQuarter
        }
      }
    	},

Based on the viewType in settings, here is the usage:
computed: {
    ...mapGetters('weeks')
  },

The problem is that after each change in the settings, you need to send the request again, in one request there are days in another weeks, but during the request the component tries to take data that has not yet arrived and throws an error. How can the getter be called after new data is received, and not before? Is it possible to do this without entering loading (like loading: false) in the state?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
E
Eugene, 2016-08-16
@myskypesla

On flexbox something like this:
https://jsfiddle.net/5mwhzr42/

B
burtulug, 2016-08-17
@burtulug

If header and footer are set to position: absolute, the content block should have vertical padding equal to the height of the header and footer - margin: 70px 0 100px;

P
Polina Emelyanova, 2016-08-19
@bugo_aneo

jsfiddle.net/AdQ3P/346 - maybe this will help??
webcareer.ru/vysota-ravnaya-shirine-na-css.html
And I couldn't sleep at all: codepen.io/emelyanova/pen/KrYyvG - such a thing as vh - can save you.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question