Service vs Model file access

So I have a model and a serviceModel… The model is a simple exported class with a few attributes and a couple of methods. The serviceModel is an ionic service

The model has many images, through a second model. I can access the images via model.images

The images are stored on the mobile filesystem. This is a must as the app has to work offline

The model can be uploaded and downloaded from an API. The modelService takes care of that.

Now the question is… how do I manage the images stored in the filesystem. I can see two options:

  • The modelService downloading the images, updating the image path and src attribute, also create directories. Basically taking care of everything related to manage the file and webview actions.

  • The modelService downloads the file to a temporary directory and send the path the the model. The model then copy the file to the correct location and creates the webview url.

The main difference is that I’ll be using cordova file and webview within the model or not.

I’m more prone for the second option, but would like your feedback before writing bunch of code.


1.According to me you should go with Second Option.
Not specific reason but I feel second option is better.

Thank you , I’ve been reading more and seams like people are not defining models on Ionic as classes but interfaces. Then modelServices take care of the interface logic, meaning all methods are implemented on the service.

Can anybody confirm if this approach is the best today with ionic 4?