Skip to content

Commit

Permalink
added isReady method
Browse files Browse the repository at this point in the history
  • Loading branch information
ehsan6sha committed Dec 30, 2022
1 parent cb80f23 commit b647368
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
17 changes: 17 additions & 0 deletions android/src/main/java/land/fx/fula/FulaModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,23 @@ public void newClient(String identityString, String storePath, String bloxAddr,
});
}

@ReactMethod
public void isReady(Promise promise) {
Log.d("ReactNative", "isReady started");
ThreadUtils.runOnExecutor(() -> {
boolean initialized = false;
try {
if (this.fula != null && this.fula.id() != null) {
initialized = true;
}
promise.resolve(initialized);
} catch (Exception e) {
Log.d("ReactNative", "isReady failed with Error: " + e.getMessage());
promise.reject("Error", e.getMessage());
}
});
}

@ReactMethod
public void init(String identityString, String storePath, String bloxAddr, String exchange, boolean autoFlush, String rootConfig, Promise promise) {
Log.d("ReactNative", "init started");
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@functionland/react-native-fula",
"version": "1.0.6",
"version": "1.0.7",
"description": "This package is a bridge to use the Fula libp2p protocols in the react-native which is using wnfs",
"main": "lib/commonjs/index",
"module": "lib/module/index",
Expand Down
1 change: 1 addition & 0 deletions src/interfaces/fulaNativeModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ interface FulaNativeModule {
exchange: string, //set to 'noope' for testing
autoFlush: boolean //set to false always unless you know what you are doing. This is to write actions to disk explicitly after each write
) => Promise<string>;
isReady: () => Promise<boolean>;
logout: (identity: string, storePath: string) => Promise<boolean>;
checkFailedActions: (retry: boolean) => Promise<boolean>;
checkConnection: () => Promise<boolean>;
Expand Down
9 changes: 9 additions & 0 deletions src/protocols/fula.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,3 +253,12 @@ export const readFileContent = (path: string): Promise<string> => {
export const shutdown = (): Promise<void> => {
return Fula.shutdown();
};

/**
* rm removes all files and folders at a given path
* @param path
* @returns string: new cid of the root
*/
export const isReady = (): Promise<boolean> => {
return Fula.isReady();
};

0 comments on commit b647368

Please sign in to comment.