Akita: Question/Suggestion: Is there a way to get static value of Loading or Error?

Created on 5 Feb 2020  Â·  4Comments  Â·  Source: datorama/akita

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[x] Support request
[ ] Other... Please describe:

Current behavior

Today, to get a static value of a loading or error i need to do something like that:


@Injectable({ providedIn: "root" })
export class Query extends QueryEntity {
    loading$ = this.selectLoading();

    constructor(protected store: Store) {
        super(store);
    }
}

const { loading } = this.query.loading$.source.source.source.getValue()

Expected behavior

I think that will be awesome if exist a way to get the static value of loading and error, aka:
this.query.getLoading() or this.quey.getError()

What is the motivation / use case for changing the behavior?

I need to use in a conditional of another context if the store are loading in that moment

Environment


Angular version: 8.2.14

For Tooling issues:
- Node version: v10.16.0
- Platform:  Windows

Most helpful comment

You can add it to your query:

class YourQuery extends QueryEntity {
  getLoading() {
    return this.getValue().loading;
  }
}

All 4 comments

You can simply call store.getValue().loading/error.
Those props exist on the root object of your state

On Wed, Feb 5, 2020, 22:13 Nathan Gabriel notifications@github.com wrote:

I'm submitting a...

[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[x] Support request
[ ] Other... Please describe:

Current behavior

Today, to get a static value of a loading or error i need to do something
like that:

@Injectable({ providedIn: "root" })
export class Query extends QueryEntity {
loading$ = this.selectLoading();

constructor(protected store: Store) {
super(store);
}
}

const { loading } = this.query.loading$.source.source.source.getValue()
Expected behavior

I think that will be awesome if exist a way to get the static value of
loading and error, aka:
this.query.getLoading() or this.quey.getError()
What is the motivation / use case for changing the behavior?

I need to use in a conditional of another context if the store are loading
in that moment
Environment

Angular version: 8.2.14

For Tooling issues:

  • Node version: v10.16.0
  • Platform: Windows

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/datorama/akita/issues/370?email_source=notifications&email_token=ABRCXZW3EJF4UGEPIUQR4ZDRBMMYDA5CNFSM4KQRLEJKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4ILKEBQA,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ABRCXZR7SQEFV67T4VCQUDDRBMMYDANCNFSM4KQRLEJA
.

@danzrou
Sorry, i'm talking about Entity Store and don't exist this method :c

Use query.getValue().loading.

You can add it to your query:

class YourQuery extends QueryEntity {
  getLoading() {
    return this.getValue().loading;
  }
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

DanielNetzer picture DanielNetzer  Â·  5Comments

twittwer picture twittwer  Â·  7Comments

brgrz picture brgrz  Â·  4Comments

zvnt picture zvnt  Â·  6Comments

hoisel picture hoisel  Â·  5Comments