BaQend is all set to go as it initializes, just make sure to verify the user's login

Currently, I am utilizing BaQend and Ionic2 to implement certain tasks at the start of my application.

1. Database Readiness

Instead of repeating this process on every page:

ionViewCanEnter(): Promise<baqend> {
        // Verify Baqend SDK readiness and wait for initialization
        return this.ready.resolve().then(db => this.db = db);
}

I attempted an alternative approach, however it did not yield the desired results:

initializeApp() {
        this.platform.ready().then(() => {
          // Platform and plugins are ready.
          // Perform any necessary native operations here.
          this.statusBar.styleDefault();
          this.splashScreen.hide();
          return this.ready.resolve().then(db => this.db = db);
        });
      }

2. User Login Status Check

During app initialization, it is essential to assess the user's login status. If the user is not logged in, prompt them to sign in using the LoginModal.

ionViewWillEnter(){
    if (this.db.User.me) {
      console.log(this.db.User.me.username,' entered HomePage with ID ', this.db.User.me.id);
    } else {
      this.openLoginModal()
      console.log('Hello Anonymous');
    }
  }

The above code functions effectively for the rootPage, although integrating it into the application startup would be more beneficial.

Any suggestions or recommendations?

Answer №1

Great observation!

After careful consideration, we have made adjustments to our ionic starter. The DBReady check has been relocated to the root view, specifically in the tabs.component.ts file of our starter. This ensures that the Rootview always waits for the database before rendering the child views.

If you choose to update the db.service.ts, you will now have access to the db exported from the SDK through:

import { db } from "baqend";

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Strategies for incorporating a JSON variable into the HttpClient query parameters in an Ionic 5 application

Currently using Ionic 5 and attempting to retrieve the IP address of the client user to include it in a URL. Here is my code: this.ipclient = this.httpClient.get("https://api.ipify.org/?format=json"); this.ipclient .subscribe(ipclient => { console.log( ...

The input field cannot accommodate the lengthy value in the Mat Select option

When a user selects a value in my mat select, it doesn't display well in the selection box. The text wraps when the selection is opened, but once a choice is made, it gets cut off without proper spacing between the ellipses and the dropdown arrow. Th ...

What is the reason behind being able to assign unidentified properties to a literal object in TypeScript?

type ExpectedType = Array<{ name: number, gender?: string }> function go1(p: ExpectedType) { } function f() { const a = [{name: 1, age: 2}] go1(a) // no error shown go1([{name: 1, age: 2}]) // error displayed ...

ADAL-Node: Unable to locate tenant groups

When the authority URL is similar to (where the domain name belongs to your tenant), an error occurs: The Get Token request returned an HTTP error: 400 with the server response stating "error description AADSTS90002 Tenant 'organizations' not ...

What is the best way to keep track of choices made in 'mat-list-option' while using 'cdk-virtual-scroll-viewport'?

I have been working on implementing mat-list-option within cdk-virtual-scroll-viewport in an Angular 14 project. I came across a demo project in Angular 11 that helped me set up this implementation. In the Angular 11 demo, scrolling functions perfectly an ...

Guide on setting the number of records to display on each page using ngx pagination in Angular 4

Successfully integrated ngx pagination in my Angular 4 project and it's functioning well. However, I'm facing a challenge in displaying the number of records per page as (Showing: 1 - 10 / 25). I've attempted to solve it but unfortunately ha ...

AmplifyJS is throwing an error: TypeError - It seems like the property 'state' is undefined and cannot be read

I am currently working on integrating the steps outlined in the Amplify walkthrough with an Angular cli application. My app is a brand new Angular cli project following the mentioned guide. My objective is to utilize the standalone auth components a ...

ngclass is not functioning properly when used with dynamically generated components

I am experiencing an issue with the components I create using createComponent. Although some of them function properly, others lack the appropriate CSS classes. Despite using a function and [ngClass] to set the classes, they do not appear when inspected in ...

What is the reason behind VS Code not showing an error when executing the command line tsc shows an error message?

Deliberately introducing a typo in my code results in an error. Here is the corrected code: declare const State: TwineState; If I remove the last character and then run tsc on the command line, it throws this error: tsc/prod.spec.ts:7:22 - error TS2304: ...

Working with relative paths in React Native TypeScript using WebStorm

My variable color is located in the path app/theme. To set it up, I created a package.json file in app/package.json with the following content: { "name": "app" } Now, to import color in TypeScript files, I use the following syntax: import { color } fro ...

What are the steps to implement the `serialport` library in `deno`?

After tinkering with Deno to extract readings from an Arduino, I encountered a roadblock when it came to using the serialport library correctly. Here is what I attempted: According to a post, packages from pika.dev should work. However, when trying to use ...

Avoiding circular imports in Angular modules

After restructuring my angular app from a monolithic shared feature module to smaller ones, I faced a challenge with what appears to be a cyclic dependency. The issue arises when I have components such as triggerA, modalA, triggerB, and modalB interacting ...

Error occurs in Angular 10 when reloading IFrame

My goal is to fetch the HTML string from an API and update an iframe with that string. The code works perfectly for the first load, but when the onBtnClick method is triggered a second time, it throws an error: VM3012:1 Uncaught SyntaxError: Identifier &ap ...

It is possible that req.user may be undefined, especially when using express and passport.js

I am facing an issue with my Node.js TypeScript authentication system that utilizes passport. The problem arises when I attempt to access req.user in a specific route, resulting in the error message: Object is possibly 'undefined'. This behavio ...

Disabling a specific tab in an array of tabs using Angular and Typescript

Displayed below are 5 tabs that can be clicked by the user. My goal is to disable tabs 2 and 3, meaning that the tab names will still be visible but users will not be able to click on them. I attempted to set the tabs to active: false in the TypeScript fi ...

Angular 2's HTTP Interceptor: Enhancing your HTTP Requests

For my Angular 2 app, I'm looking to include an HTTP interceptor that will verify the HTTP status code for each response. In case the status code is 401, I would like to automatically redirect the user to the login page. Does anyone know of a straigh ...

Ways to transmit information or notifications from a service to a component

Currently, I am utilizing Angular 6 and have the upload file control on three different screens (three various components). Each of these screens calls the same method UploadFile(). The main issue arises when I need to make any changes to this method, as ...

What is the issue when using TypeScript if my class contains private properties while the object I provide contains public properties?

I am currently facing an issue while attempting to create a typescript class with private properties that are initialized in the constructor using an object. Unfortunately, I keep encountering an error message stating: "error TS2345: Argument of type &apos ...

Tips for making use of incomplete types

Is there a way to reference a type in TypeScript without including all of its required fields, without creating a new interface or making all fields optional? Consider the following scenario: interface Test { one: string; two: string; } _.findWhe ...

A single pledge fulfilled in two distinct ways

My code ended up with a promise that raised some questions. Is it acceptable to resolve one condition with the token string value (resolve(token)), while resolving another condition with a promise of type Promise<string>: resolve(resultPromise); con ...