Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

ExchangeContext or pass Script instance

Featured Replies

Suppose I have these three classes:

Main (exchangesContext with BankTask), BankTask , Data (Data class contains methods which require api access)

Let's say the BankTask needs to use some methods from the Data class. I realised that I need to call exchangeContext inside BankTask aswell but there's obviously no onStart method there.

Should I let the Data class accept MethodProvider in its constructor instead or is it possible or even preferable to use exchangeContext in such cases?

Edited by Jammer

56 minutes ago, Jammer said:

Suppose I have these three classes:

Main (exchangesContext with BankTask), BankTask , Data (Data class contains methods which require api access)

Let's say the BankTask needs to use some methods from the Data class. I realised that I need to call exchangeContext inside BankTask aswell but there's obviously no onStart method there.

Should I let the Data class accept MethodProvider in its constructor instead or is it possible or even preferable to use exchangeContext in such cases?

 

You could always override the exchangeContext method to also exchangeContext with instances within your class:

public class BankTask extends Task {

    SomeOtherClassThatNeedsApi someOtherClass = new SomeOtherClassThatNeedsApi();
  
    @Override
    public MethodProvider exchangeContext(Bot bot) {
        super.exchangeContext(bot);
        someOtherClass.exchangeContext(bot);
        return this;
    }
  
    // ... Blah blah whatever
}

 

Or yes just pass MethodProvider as a parameter to the constructor of your other class.

Or just add an onStart method to your base Task class and call it once before executing a Task. This may or may not be appropriate depending on what your "Task" pattern is.

Edited by Explv

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.