Skip to content

Conversation

@matthewwithanm
Copy link
Contributor

This adds one word ("return") and a test (:

The idea is that it makes the context method more of a transparent wrapping. This comes in handy with anything where the return value matters—for example, RequireJS:

Without Raven

define(function (require) {
    var result = doSomething();
    return {
        something: result.anything
    };
});

With Raven

define(function (require) {
    var result;
    // require raven yada yada

    Raven.context(function () {
        result = doSomething();
    });

    return {
        something: result.anything
    };
});

With Raven + This Change

define(function (require) {
    // require raven yada yada

    return  Raven.context(function () {
        var result = doSomething();
        return {
            something: result.anything
        };
    });
});

This allows you wrap your entire module with little change (and without having to worry if you missed some errors that were done after the context call). It's even nicer in CoffeeScript thanks to the implicit returns:

Without Raven

define (require) ->
  result = doSomething()

  # Exports
  something: result.anything

With Raven + This Change

define (require) ->
  # require raven yada yada

  Raven.context ->
    result = doSomething()

    # Exports
    something: result.anything

Basically, you just need to indent your code an extra level, as opposed with the current behavior where you need to create a variable in the outer context and close over it.

These are small examples to get the point across but obviously it has more of an impact as the amount of code grows.

mattrobenolt added a commit that referenced this pull request Oct 17, 2013
Return result of wrapped function from context
@mattrobenolt mattrobenolt merged commit 3a00b45 into getsentry:master Oct 17, 2013
@mattrobenolt
Copy link
Contributor

Looks sensible to me! Thanks. 👍

@matthewwithanm matthewwithanm deleted the return-from-context branch October 17, 2013 21:26
@matthewwithanm
Copy link
Contributor Author

No problem! Any idea when the next release'll be? Seems like it's been a while.

@mattrobenolt
Copy link
Contributor

It has been a while. We are planning to get together this weekend and figure out the tooling and whatnot for this. I built some stuff that made things more difficult to do releases, so it has been a pain point. We're gonna switch to grunt and whatnot this weekend and get things into some standard tools.

Also, finishing ravenjs.com as well for downloading custom built versions from our new CDN. :)

@matthewwithanm
Copy link
Contributor Author

Cool. Thanks for all the hard work (:

mydea added a commit that referenced this pull request Jan 5, 2024
- fix(rrweb): Use unpatched requestAnimationFrame when possible [#150](getsentry/rrweb#150)
- ref: Avoid async in canvas (#143)
- feat: Bundle canvas worker manually (#144)
- build: Build for ES2020 (#142)
mydea added a commit that referenced this pull request Jan 8, 2024
- fix(rrweb): Use unpatched requestAnimationFrame when possible [#150](getsentry/rrweb#150)
- ref: Avoid async in canvas (#143)
- feat: Bundle canvas worker manually (#144)
- build: Build for ES2020 (#142)
mydea added a commit that referenced this pull request Jan 10, 2024
This bump contains the following changes:

- fix(rrweb): Use unpatched requestAnimationFrame when possible
[#150](getsentry/rrweb#150)
- ref: Avoid async in canvas
[#143](getsentry/rrweb#143)
- feat: Bundle canvas worker manually
[#144](getsentry/rrweb#144)
- build: Build for ES2020
[#142](getsentry/rrweb#142)

Extracted out from
#9826

Closes #6946
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants