Resource category make flow

In Respresso we defined categories for grouping similar resources together. (Localization, Image, Colors, etc.) This category’a make flow’s responsibility to execute the required actions to take the category’s state from input.current to input.newState. This flow will receive a ResourceCategoryConversionExecutorInputStructure to it’s input when the Save button is clicked on the web interface of the category.

Make resource category

As mentioned above a flow will be executed when the Save button is clicked. This flow will have to decide what conversion is needed and what converted files should be kept without change. To make it easier, we created ResourceCategoryConversionExecutorProcessor which can handle most of this for you. For the concrete usage please read it’s docs. The result will contain file change requests which will take the current version of the category to the new state. These actions can contain new files, modifications to existing ones and Keep requests which means that the content of an existing converted file is up to date.

When these requests are successfully created that means no error has occurred during the conversion so we can assume that the requested new state is consistent. At this point we are ready to persist these changes, like a commit in a transaction. This commit point is represented by StoreChangedResourceCategoryProcessor which will check if the requested changes are consistent and execute them. This means that it will create the new files, keep or replace the existing files and delete the not mentioned ones. At the end it will persist the new category snapshot.

So what makes the difference between the categories?

The real conversion not happens here. It is executed by ResourceCategoryConversionExecutorProcessor and defined by it’s config. In this config you can specify in what case should it execute the conversion of a specific resource and which flow represents that conversion. On the other hand you have an option to convert a full category not a separate resource like we do with localization. For the concrete usage please read it’s docs.

Conversion flows

As mentioned above ResourceCategoryConversionExecutorProcessor supports two type of flows with a really similar interface. But take a closer look, what is the difference?

Single resource converter flow

This flow can be executed multiple times. This is because it is executed in a forEachIf like sequence on the resources in the new state of the category. This should convert only that resource named in the targetResource field on the input.

All resources converter flow

This flow represents the conversion of the full category. None of the files returned by it should be tied to a specific resource. This is used when you have to generate a summary file for the category. Like we do with localization: We generate a helper class for iOS to easily access the keys or the translated value from code without typos. This file contains all the keys of the localization but not contains any translation. (A localization key is a separate resource in our system.)