Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to addon changes #169

Merged
merged 12 commits into from
Nov 6, 2022
Merged

Conversation

florian-h05
Copy link
Contributor

@florian-h05 florian-h05 commented Nov 5, 2022

Fixes #168.

Changes

  • Update docs & workflows for NodeJS v16.17.1
  • Update package-lock for NodeJS v16.17.1
  • README: Mention that the timer polyfills behave now like standard JS
  • README: Remove the openHAB Timer and the raw timer creation methods
  • README: Add a warning for changing logger names
  • README: Explain access to vars in the standard JS timer methods (e.g. function generator)
  • actions: Log warning when the raw timer creation methods are accessed
  • Clean & Upgrade some dev dependencies

Testing

I have also verified that the library is still working under older versions of the addon that are running an older GraalJS and therefore NodeJS version.

Use the following script to verify all relevant changes:

const { actions, time } = require('openhab');

// Test whether access to raw timer creation methods is still possible but logs a warning
const now = time.ZonedDateTime.now();

actions.ScriptExecution.createTimer('timer1', now.plusSeconds(2), () => {
  console.info('Timer with identifier ran');
});
actions.ScriptExecution.createTimer(now.plusSeconds(4), () => {
  console.info('Timer without identifier ran');
});

const foo = 'myVar';

actions.ScriptExecution.createTimerWithArgument('timer2', now.plusSeconds(6), foo, () => {
  console.info('Timer with identifier and var ran: ' + foo);
});

actions.ScriptExecution.createTimerWithArgument(now.plusSeconds(8), foo, () => {
  console.info('Timer without identifier and with var ran: ' + foo);
});

// Test examples from the README updates

// Example 1

var myVar = 'Hello world!';

// Schedule a timer that expires in ten seconds
setTimeout(() => {
  console.info(`Timer expired with myVar = "${myVar}"`);
}, 10000);

myVar = 'Hello mutation!'; // When the timer runs, it will log "Hello mutation!" instead of "Hello world!"

// Example 2

// Function generator for the timer's callback function
function cbFuncGen (myVariable) {
  return function () {
    console.info(`Timer expired with myVar = "${myVariable}"`);
  };
}

var bar = 'Hello world!';

// Schedule a timer that expires in ten seconds
setTimeout(cbFuncGen(bar), 12000);

bar = 'Hello mutation!'; // When the timer runs, it will log "Hello world!"

@florian-h05 florian-h05 added documentation Improvements or additions to documentation enhancement New feature or request workinprogress Work in Progress — not completed or tested labels Nov 5, 2022
@florian-h05
Copy link
Contributor Author

florian-h05 commented Nov 5, 2022

@digitaldan @jpg0 @rkoshak (sorry for pinging you all)
This is the follow-up PR for openhab/openhab-addons#13623.

Could any of you please review?
We haven't much time time left to get this into the milestone, so at some point I will merge without review.

@florian-h05 florian-h05 removed the workinprogress Work in Progress — not completed or tested label Nov 5, 2022
@florian-h05 florian-h05 changed the title [WIP] Update to addon changes Update to addon changes Nov 5, 2022
@jlaur
Copy link
Contributor

jlaur commented Nov 5, 2022

Could any of you please review?

I'm no JavaScript expert and not a maintainer of this repository, so I'm afraid I can't help much. When you have this PR reviewed and merged and a new lib is released, I'll of course help merging the new version into the addons repository.

@florian-h05 florian-h05 requested a review from jpg0 November 5, 2022 16:09
@florian-h05 florian-h05 added this to the 2.x.x milestone Nov 5, 2022
Signed-off-by: Florian Hotze <[email protected]>
@florian-h05
Copy link
Contributor Author

@jlaur

I'm no JavaScript expert and not a maintainer of this repository, so I'm afraid I can't help much.

You wouldn't be the first reviewer that is no maintainer, since we are only two maintainers and digitaldan is not always available when a time critic PR needs to be merged.

I am aware that you are no JS expert, but it would be great if you could have a look at the README changes.

When you have this PR reviewed and merged and a new lib is released, I'll of course help merging the new version into the addons repository.

I will definitely come back to that offer!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update library to addon changes
2 participants