Node conf ar 2018.

Node conf ar 2018.

E807477655ad7125c8731065178030e2?s=128

Willian Martins

October 19, 2018
Tweet

Transcript

  1. ¡Hola!

  2. https://github.com/tc39/proposals

  3. v. NodeConf Ar

  4. @wmsbill What is this?

  5. @wmsbill this in the global scope Browser - window Web

    worker - self NodeJS - module.exports
  6. @wmsbill this inside a function?

  7. @wmsbill this inside a function?

  8. @wmsbill What is this?

  9. @wmsbill What is this?

  10. @wmsbill this inside a function Browser - window NodeJS -

    global object
  11. @wmsbill this with new operator

  12. @wmsbill this with new operator

  13. @wmsbill this with strict mode

  14. @wmsbill this with strict mode

  15. @wmsbill Setting this value Function.prototype.call Function.prototype.apply Function.prototype.bind new operator Object

    member function
  16. @wmsbill Setting this value

  17. @wmsbill How to make this predictable? Reasoning the value of

    this is tricky Function.prototype.bind Arrow function () => {}
  18. None
  19. With .bind()

  20. With Arrow

  21. @wmsbill Calling a knowing function

  22. @wmsbill Extracting a method from an object

  23. None
  24. @wmsbill Two syntaxes Unary : :context.method() Binary context: :method()

  25. @wmsbill Unary syntax

  26. @wmsbill Binary syntax

  27. @wmsbill

  28. @wmsbill

  29. @wmsbill

  30. @wmsbill Bind operator is good for virtual methods But relies

    on this to be bound
  31. @wmsbill Composing without this

  32. @wmsbill

  33. @wmsbill

  34. None
  35. @wmsbill Pipeline operator |> It is a syntax sugar for

    function composition It creates a way to streamline a chain of functions
  36. @wmsbill Pipeline operator |>

  37. @wmsbill

  38. @wmsbill

  39. @wmsbill

  40. @wmsbill Function with more params

  41. @wmsbill Function with more params

  42. @wmsbill Awaiting a function

  43. @wmsbill Awaiting a function

  44. @wmsbill Awaiting a function

  45. @wmsbill Awaiting a function

  46. @wmsbill Awaiting a function

  47. None
  48. @wmsbill Smart pipeline

  49. @wmsbill Smart pipeline Two types bare style and topic style

    () or [] are disallowed in bare style When () or [] is needed, topic style is used # token is subject to change
  50. @wmsbill What about curry?

  51. None
  52. @wmsbill F# pipeline proposal Extends the minimal proposal with an

    await step Await step waits for the resolution of the previous step
  53. @wmsbill F# pipeline proposal

  54. @wmsbill

  55. @wmsbill Partial application f(…) arity = n; partialapp(f(…)) arity =

    m; m < n
  56. @wmsbill

  57. @wmsbill

  58. @wmsbill Partial application in ES Achievable by Function.prototype.bind .bind() binds

    context and parameters
  59. @wmsbill

  60. @wmsbill What about currying? We can achieve partial application with

    curry Curry ≠ Partial application Curry returns arity n-1
  61. @wmsbill

  62. @wmsbill Partial application with arrow function

  63. None
  64. @wmsbill Partial application proposal Creates two new parameters tokens ?

    For single argument . . . for multiple parameters (not in the initial spec anymore)
  65. @wmsbill Partial application syntax

  66. @wmsbill With arbitrary parameter

  67. None
  68. @wmsbill Partial application in template string

  69. @wmsbill Partial application in template string

  70. None
  71. @wmsbill The . . . token Spread the unbound parameters

    Useful when you want to bound first or last parameter
  72. @wmsbill The . . . token

  73. @wmsbill The . . . token

  74. @wmsbill Partial application + pipeline

  75. @wmsbill Partial application + pipeline

  76. @wmsbill Should I use all of it in production? These

    proposal are in very early stage The adoption of one, may change the syntax/semantics of other Not production ready (yet)
  77. https://medium.com/@wmsbill https://twitter.com/wmsbill wmsbill@gmail.com https://www.smashingmagazine.com/2018/10/taming-this-javascript-bind- operator/

  78. ¡Gracias!